Skip to content

Commit 5345613

Browse files
panvaaduh95
authored andcommitted
test: deflake inspector network fetch
A Windows socket bound to 127.0.0.1 can accept connections intended for another process's wildcard listener on the same port. A competing inspector can then answer the HTTP request with 400 or send plaintext to the HTTPS client. Bind both fixture servers to the address used by their requests to prevent the competing bind. Bypass environment proxies so local HTTP and HTTPS requests reach the fixture servers directly, and remove the Windows flaky expectation. Fixes: #59090 Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Claude, Codex PR-URL: #66320 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 25c08fc commit 5345613

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

‎test/parallel/parallel.status‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ test-fs-read-stream-concurrent-reads: PASS, FLAKY
2020
test-snapshot-incompatible: SKIP
2121

2222
[$system==win32]
23-
# https://github.com/nodejs/node/issues/59090
24-
test-inspector-network-fetch: PASS, FLAKY
2523
# https://github.com/nodejs/node/issues/59636
2624
test-fs-cp-sync-symlink-points-to-dest-error: SKIP
2725
test-fs-cp-async-symlink-points-to-dest: SKIP

‎test/parallel/test-inspector-network-fetch.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ const http = require('node:http');
1212
const https = require('node:https');
1313
const inspector = require('node:inspector/promises');
1414

15-
// Disable certificate validation for the global fetch.
15+
// Keep local requests independent of proxy settings and allow the test certificate.
1616
const undici = require('internal/deps/undici/undici');
1717
undici.setGlobalDispatcher(new undici.EnvHttpProxyAgent({
18+
noProxy: '*',
1819
connect: {
1920
rejectUnauthorized: false,
2021
},
@@ -205,8 +206,10 @@ const testNetworkInspection = async () => {
205206
session.removeAllListeners();
206207
};
207208

208-
httpServer.listen(0, () => {
209-
httpsServer.listen(0, async () => {
209+
// Listen on the address the requests go to, so that a socket another process
210+
// binds to 127.0.0.1 on the same port cannot take the connections over.
211+
httpServer.listen(0, '127.0.0.1', () => {
212+
httpsServer.listen(0, '127.0.0.1', async () => {
210213
try {
211214
await session.post('Network.enable');
212215
await testNetworkInspection();

0 commit comments

Comments
 (0)