diff --git a/docs/yarn.lock b/docs/yarn.lock index c11466c61..0443c33f8 100644 --- a/docs/yarn.lock +++ b/docs/yarn.lock @@ -1686,9 +1686,9 @@ camelcase@^8.0.0: integrity sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA== caniuse-lite@^1.0.30001669: - version "1.0.30001680" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001680.tgz#5380ede637a33b9f9f1fc6045ea99bd142f3da5e" - integrity sha512-rPQy70G6AGUMnbwS1z6Xg+RkHYPAi18ihs47GH0jcxIG7wArmPgY3XbS2sRdBbxJljp3thdT8BIqv9ccCypiPA== + version "1.0.30001682" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001682.tgz#e44dab724829893a4e4fe679ed077eb4cdc34039" + integrity sha512-rJFwz3yRO6NU6Y8aEJKPzS4fngOE8j05pd33FW5Uk9v9b5StWNhGFeVpogwS2FFl78wNDGW5NsVvlwySPEDU5w== ccount@^2.0.0: version "2.0.1" diff --git a/package.json b/package.json index a299ecd17..ff68d064d 100644 --- a/package.json +++ b/package.json @@ -92,8 +92,5 @@ "npm-check-updates": "^17.1.11", "prettier": "^3.3.3", "zx": "^8.2.2" - }, - "dependencies": { - "https-proxy-agent": "^7.0.5" } } diff --git a/packages/core/package.json b/packages/core/package.json index 79cb4995c..84d3dd1ce 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -52,6 +52,7 @@ "gpt-tokenizer": "^2.6.2", "html-escaper": "^3.0.3", "html-to-text": "^9.0.5", + "https-proxy-agent": "^7.0.5", "ignore": "^6.0.2", "inflection": "^3.0.0", "ini": "^5.0.0", diff --git a/packages/core/src/fetch.ts b/packages/core/src/fetch.ts index 87e6b208a..05880c030 100644 --- a/packages/core/src/fetch.ts +++ b/packages/core/src/fetch.ts @@ -11,13 +11,7 @@ import { errorMessage } from "./error" import { logVerbose, roundWithPrecision, toStringList } from "./util" import { CancellationToken } from "./cancellation" import { readText } from "./fs" -import { HttpsProxyAgent } from 'https-proxy-agent'; - - -// We create a proxy based on Node.js environment variables. -const proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY; -const agent = proxy ? new HttpsProxyAgent(proxy) : null; - +import { HttpsProxyAgent } from "https-proxy-agent" /** * Creates a fetch function with retry logic. @@ -47,11 +41,15 @@ export async function createFetch( cancellationToken, } = options || {} - // We enrich crossFetch with the proxy. - let crossFetchWithProxy = (url: string | WorkspaceFile, options = {}) => { - return crossFetch(url, { ...options, agent }) - }; + // We create a proxy based on Node.js environment variables. + const proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY + const agent = proxy ? new HttpsProxyAgent(proxy) : null + // We enrich crossFetch with the proxy. + const crossFetchWithProxy: typeof fetch = agent + ? (url, options) => + crossFetch(url, { ...(options || {}), agent } as any) + : crossFetch // Return the default fetch if no retry status codes are specified if (!retryOn?.length) return crossFetchWithProxy @@ -177,11 +175,11 @@ export function traceFetchPost( : "***") // Mask other authorization headers ) const cmd = `curl ${url} \\ +--no-buffer \\ ${Object.entries(headers) .map(([k, v]) => `-H "${k}: ${v}"`) - .join("\\\n")} \\ + .join(" \\\n")} \\ -d '${JSON.stringify(body, null, 2).replace(/'/g, "'\\''")}' ---no-buffer ` if (trace) trace.detailsFenced(`✉️ fetch`, cmd, "bash") else logVerbose(cmd) diff --git a/slides/yarn.lock b/slides/yarn.lock index e4559f094..8a1f19d37 100644 --- a/slides/yarn.lock +++ b/slides/yarn.lock @@ -2068,9 +2068,9 @@ cacheable-request@^10.2.8: responselike "^3.0.0" caniuse-lite@^1.0.30001669: - version "1.0.30001680" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001680.tgz#5380ede637a33b9f9f1fc6045ea99bd142f3da5e" - integrity sha512-rPQy70G6AGUMnbwS1z6Xg+RkHYPAi18ihs47GH0jcxIG7wArmPgY3XbS2sRdBbxJljp3thdT8BIqv9ccCypiPA== + version "1.0.30001682" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001682.tgz#e44dab724829893a4e4fe679ed077eb4cdc34039" + integrity sha512-rJFwz3yRO6NU6Y8aEJKPzS4fngOE8j05pd33FW5Uk9v9b5StWNhGFeVpogwS2FFl78wNDGW5NsVvlwySPEDU5w== ccount@^2.0.0: version "2.0.1" diff --git a/yarn.lock b/yarn.lock index b0eeb67a2..6065b4768 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3380,7 +3380,7 @@ https-proxy-agent@^5.0.0: agent-base "6" debug "4" -https-proxy-agent@^7.0.0: +https-proxy-agent@^7.0.0, https-proxy-agent@^7.0.5: version "7.0.5" resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz#9e8b5013873299e11fab6fd548405da2d6c602b2" integrity sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==