From 5f32f2f597aa04bdc1f282e9fecd34cdf90bf1ac Mon Sep 17 00:00:00 2001 From: Vita Batrla Date: Wed, 21 Jan 2026 21:46:33 +0100 Subject: [PATCH 1/8] test: user proxy settings break proxy tests Some client-proxy tests set HTTP_PROXY variable in the environment. It's OK in general, however, in some specific cases, the user might have already defined his own http_proxy setting in the environment. The lowercase user setting takes precedence and leads to a test failure. The fix cleans up the environment to avoid an interaction between user and test proxy settings. --- test/common/proxy-server.js | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/test/common/proxy-server.js b/test/common/proxy-server.js index c4cd19fe610b81..b5ed41a8b3af1d 100644 --- a/test/common/proxy-server.js +++ b/test/common/proxy-server.js @@ -151,17 +151,21 @@ function spawnPromisified(...args) { }); } +function spawnOptions(envExtension) { + /* + * Cleanup the environment to not interfere with the client proxy tests. + */ + const { http_proxy, https_proxy, HTTP_PROXY, HTTPS_PROXY, + no_proxy, NO_PROXY, ...env } = process.env; + return { env: {...env, ...envExtension} }; +} + async function checkProxied(type, envExtension, expectation, cliArgsExtension = []) { const script = type === 'fetch' ? fixtures.path('fetch-and-log.mjs') : fixtures.path('request-and-log.js'); const { code, signal, stdout, stderr } = await spawnPromisified( process.execPath, - [...cliArgsExtension, script], { - env: { - NO_LOG_REQUEST: '1', - ...process.env, - ...envExtension, - }, - }); + [...cliArgsExtension, script], + spawnOptions({...envExtension, NO_LOG_REQUEST: '1'})); assert.deepStrictEqual({ stderr: stderr.trim(), @@ -188,24 +192,16 @@ exports.runProxiedRequest = async function(envExtension, cliArgsExtension = []) const fixtures = require('./fixtures'); return spawnPromisified( process.execPath, - [...cliArgsExtension, fixtures.path('request-and-log.js')], { - env: { - ...process.env, - ...envExtension, - }, - }); + [...cliArgsExtension, fixtures.path('request-and-log.js')], + spawnOptions(envExtension)); }; exports.runProxiedPOST = async function(envExtension) { const fixtures = require('./fixtures'); return spawnPromisified( process.execPath, - [fixtures.path('post-resource-and-log.js')], { - env: { - ...process.env, - ...envExtension, - }, - }); + [fixtures.path('post-resource-and-log.js')], + spawnOptions(envExtension)); }; exports.startTestServers = async function(options = {}) { From c52d7f71f717a8916d046970a1a2677038d496a7 Mon Sep 17 00:00:00 2001 From: Vita Batrla Date: Wed, 21 Jan 2026 22:47:45 +0100 Subject: [PATCH 2/8] fix lint --- test/common/proxy-server.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/test/common/proxy-server.js b/test/common/proxy-server.js index b5ed41a8b3af1d..6e968467efbe6c 100644 --- a/test/common/proxy-server.js +++ b/test/common/proxy-server.js @@ -152,12 +152,17 @@ function spawnPromisified(...args) { } function spawnOptions(envExtension) { - /* - * Cleanup the environment to not interfere with the client proxy tests. - */ - const { http_proxy, https_proxy, HTTP_PROXY, HTTPS_PROXY, - no_proxy, NO_PROXY, ...env } = process.env; - return { env: {...env, ...envExtension} }; + // Cleanup the environment to not interfere with the client proxy tests. + const { + http_proxy: _http_proxy, + https_proxy: _https_proxy, + HTTP_PROXY: _HTTP_PROXY, + HTTPS_PROXY: _HTTPS_PROXY, + no_proxy: _no_proxy, + NO_PROXY: _NO_PROXY, + ...env + } = process.env; + return { env: { ...env, ...envExtension } }; } async function checkProxied(type, envExtension, expectation, cliArgsExtension = []) { @@ -165,7 +170,7 @@ async function checkProxied(type, envExtension, expectation, cliArgsExtension = const { code, signal, stdout, stderr } = await spawnPromisified( process.execPath, [...cliArgsExtension, script], - spawnOptions({...envExtension, NO_LOG_REQUEST: '1'})); + spawnOptions({ ...envExtension, NO_LOG_REQUEST: '1' })); assert.deepStrictEqual({ stderr: stderr.trim(), From acef838a5bb84292d26469dc29072ba2066e75c6 Mon Sep 17 00:00:00 2001 From: Vita Batrla Date: Wed, 21 Jan 2026 22:50:31 +0100 Subject: [PATCH 3/8] reword the comment --- test/common/proxy-server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common/proxy-server.js b/test/common/proxy-server.js index 6e968467efbe6c..b4b9fb2863bac6 100644 --- a/test/common/proxy-server.js +++ b/test/common/proxy-server.js @@ -152,7 +152,7 @@ function spawnPromisified(...args) { } function spawnOptions(envExtension) { - // Cleanup the environment to not interfere with the client proxy tests. + // Cleanup the environment to avoid interference with client proxy tests. const { http_proxy: _http_proxy, https_proxy: _https_proxy, From 32e87d8aaee125a64c76ea972d23638144b10b11 Mon Sep 17 00:00:00 2001 From: Vita Batrla Date: Thu, 22 Jan 2026 09:42:15 +0100 Subject: [PATCH 4/8] eslint still complains, use for loop --- test/common/proxy-server.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/test/common/proxy-server.js b/test/common/proxy-server.js index b4b9fb2863bac6..30cb5178d82688 100644 --- a/test/common/proxy-server.js +++ b/test/common/proxy-server.js @@ -152,16 +152,12 @@ function spawnPromisified(...args) { } function spawnOptions(envExtension) { + const env = { ...process.env }; // Cleanup the environment to avoid interference with client proxy tests. - const { - http_proxy: _http_proxy, - https_proxy: _https_proxy, - HTTP_PROXY: _HTTP_PROXY, - HTTPS_PROXY: _HTTPS_PROXY, - no_proxy: _no_proxy, - NO_PROXY: _NO_PROXY, - ...env - } = process.env; + for (const key of ["http_proxy", "https_proxy", "no_proxy"]) { + delete env[key]; + delete env[key.toUpper()]; + } return { env: { ...env, ...envExtension } }; } From c71a61023c7597209fee0d17aac25fa6dc03a949 Mon Sep 17 00:00:00 2001 From: Vita Batrla Date: Thu, 22 Jan 2026 09:49:38 +0100 Subject: [PATCH 5/8] use singlequote --- test/common/proxy-server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common/proxy-server.js b/test/common/proxy-server.js index 30cb5178d82688..3150f12fa5fb5c 100644 --- a/test/common/proxy-server.js +++ b/test/common/proxy-server.js @@ -154,7 +154,7 @@ function spawnPromisified(...args) { function spawnOptions(envExtension) { const env = { ...process.env }; // Cleanup the environment to avoid interference with client proxy tests. - for (const key of ["http_proxy", "https_proxy", "no_proxy"]) { + for (const key of ['http_proxy', 'https_proxy', 'no_proxy']) { delete env[key]; delete env[key.toUpper()]; } From 81bffa096bf518fa81829f56500d9df64672b197 Mon Sep 17 00:00:00 2001 From: Vita Batrla Date: Thu, 22 Jan 2026 10:14:48 +0100 Subject: [PATCH 6/8] two other tests fail behind proxy toUpper() -> toUpperCase() --- test/common/proxy-server.js | 2 +- test/parallel/test-http2-allow-http1-upgrade-ws.js | 3 ++- test/parallel/test-inspector-network-fetch.js | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/common/proxy-server.js b/test/common/proxy-server.js index 3150f12fa5fb5c..192a6e51a9165c 100644 --- a/test/common/proxy-server.js +++ b/test/common/proxy-server.js @@ -156,7 +156,7 @@ function spawnOptions(envExtension) { // Cleanup the environment to avoid interference with client proxy tests. for (const key of ['http_proxy', 'https_proxy', 'no_proxy']) { delete env[key]; - delete env[key.toUpper()]; + delete env[key.toUpperCase()]; } return { env: { ...env, ...envExtension } }; } diff --git a/test/parallel/test-http2-allow-http1-upgrade-ws.js b/test/parallel/test-http2-allow-http1-upgrade-ws.js index 028dc4e4cde71c..4e52d322923648 100644 --- a/test/parallel/test-http2-allow-http1-upgrade-ws.js +++ b/test/parallel/test-http2-allow-http1-upgrade-ws.js @@ -25,7 +25,8 @@ const WebSocketServer = require('../common/websocket-server'); await new Promise((resolve, reject) => { const ws = new WebSocket(`wss://localhost:${server.address().port}`, { dispatcher: new undici.EnvHttpProxyAgent({ - connect: { rejectUnauthorized: false } + connect: { rejectUnauthorized: false }, + noProxy: "localhost", }) }); ws.addEventListener('open', common.mustCall(() => { diff --git a/test/parallel/test-inspector-network-fetch.js b/test/parallel/test-inspector-network-fetch.js index 790446c84bfb66..928ed8349cc4dd 100644 --- a/test/parallel/test-inspector-network-fetch.js +++ b/test/parallel/test-inspector-network-fetch.js @@ -18,6 +18,7 @@ undici.setGlobalDispatcher(new undici.EnvHttpProxyAgent({ connect: { rejectUnauthorized: false, }, + noProxy: "localhost", })); const session = new inspector.Session(); From 11748f94b2accc24ccf312293fdcd1637237da93 Mon Sep 17 00:00:00 2001 From: Vita Batrla Date: Thu, 22 Jan 2026 10:34:52 +0100 Subject: [PATCH 7/8] singlequote again --- test/parallel/test-http2-allow-http1-upgrade-ws.js | 2 +- test/parallel/test-inspector-network-fetch.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http2-allow-http1-upgrade-ws.js b/test/parallel/test-http2-allow-http1-upgrade-ws.js index 4e52d322923648..067f51124a5717 100644 --- a/test/parallel/test-http2-allow-http1-upgrade-ws.js +++ b/test/parallel/test-http2-allow-http1-upgrade-ws.js @@ -26,7 +26,7 @@ const WebSocketServer = require('../common/websocket-server'); const ws = new WebSocket(`wss://localhost:${server.address().port}`, { dispatcher: new undici.EnvHttpProxyAgent({ connect: { rejectUnauthorized: false }, - noProxy: "localhost", + noProxy: 'localhost', }) }); ws.addEventListener('open', common.mustCall(() => { diff --git a/test/parallel/test-inspector-network-fetch.js b/test/parallel/test-inspector-network-fetch.js index 928ed8349cc4dd..f77fc81dd9e738 100644 --- a/test/parallel/test-inspector-network-fetch.js +++ b/test/parallel/test-inspector-network-fetch.js @@ -18,7 +18,7 @@ undici.setGlobalDispatcher(new undici.EnvHttpProxyAgent({ connect: { rejectUnauthorized: false, }, - noProxy: "localhost", + noProxy: 'localhost', })); const session = new inspector.Session(); From b701705afcdbbdebc99abac6a010eaaa331fe6b6 Mon Sep 17 00:00:00 2001 From: Vita Batrla Date: Thu, 22 Jan 2026 11:48:05 +0100 Subject: [PATCH 8/8] need to use * wildcard in noProxy --- test/parallel/test-http2-allow-http1-upgrade-ws.js | 2 +- test/parallel/test-inspector-network-fetch.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http2-allow-http1-upgrade-ws.js b/test/parallel/test-http2-allow-http1-upgrade-ws.js index 067f51124a5717..2988071650d12c 100644 --- a/test/parallel/test-http2-allow-http1-upgrade-ws.js +++ b/test/parallel/test-http2-allow-http1-upgrade-ws.js @@ -26,7 +26,7 @@ const WebSocketServer = require('../common/websocket-server'); const ws = new WebSocket(`wss://localhost:${server.address().port}`, { dispatcher: new undici.EnvHttpProxyAgent({ connect: { rejectUnauthorized: false }, - noProxy: 'localhost', + noProxy: '*', }) }); ws.addEventListener('open', common.mustCall(() => { diff --git a/test/parallel/test-inspector-network-fetch.js b/test/parallel/test-inspector-network-fetch.js index f77fc81dd9e738..d86049b9c0009e 100644 --- a/test/parallel/test-inspector-network-fetch.js +++ b/test/parallel/test-inspector-network-fetch.js @@ -18,7 +18,7 @@ undici.setGlobalDispatcher(new undici.EnvHttpProxyAgent({ connect: { rejectUnauthorized: false, }, - noProxy: 'localhost', + noProxy: '*', })); const session = new inspector.Session();