Files
oh-my-pi/packages/coding-agent/test/utils/fetch-timeout.test.ts
T
roboomp 42cbee962f fix(update): surface actionable message for unsupported proxy schemes
omp update re-threw Bun's raw fetch() UnsupportedProxyProtocol error, telling CLI users to pass verbose:true to fetch() — an instruction unavailable through the CLI. The update fetch catches now detect this failure and report which proxy env var uses an unsupported scheme plus the http/https requirement.

Fixes #8784
2026-08-17 03:08:38 +00:00

28 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import { isUnsupportedProxyError, unsupportedProxyMessage } from "../../src/utils/fetch-timeout";
describe("isUnsupportedProxyError", () => {
it("matches Bun's UnsupportedProxyProtocol rejection and nothing else", () => {
expect(isUnsupportedProxyError(new Error('UnsupportedProxyProtocol fetching "https://x"'))).toBe(true);
expect(isUnsupportedProxyError(new Error("ConnectionRefused"))).toBe(false);
expect(isUnsupportedProxyError("UnsupportedProxyProtocol")).toBe(false);
});
});
describe("unsupportedProxyMessage", () => {
it("names the proxy env var whose scheme Bun's fetch cannot use", () => {
const message = unsupportedProxyMessage({
HTTPS_PROXY: "socks5h://127.0.0.1:1080",
NO_PROXY: "localhost",
});
expect(message).toContain("HTTPS_PROXY=socks5h://127.0.0.1:1080");
expect(message).toMatch(/http:\/\//);
});
it("does not flag http(s) proxy vars as offending", () => {
const message = unsupportedProxyMessage({ HTTP_PROXY: "http://127.0.0.1:8080" });
expect(message).not.toContain("offending");
expect(message).toContain("Only http:// and https:// proxies are supported");
});
});