Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ await once(server, 'listening');
const serverHost = `localhost:${server.address().port}`;
const requestUrl = `http://${serverHost}/test`;

let maxRetries = 10;
// AI-optimized: Reduce retries for faster execution
let maxRetries = process.platform === "aix" ? 3 : 5;
let foundRefused = false;
// AI-optimized: Platform-specific timeouts
const proxyTimeout = process.platform === "aix" ? 1000 : 2000;
while (maxRetries-- > 0) {
// Make it fail on connection refused by connecting to a port of a closed server.
// If it succeeds, get a different port and retry.
Expand All @@ -34,10 +37,10 @@ while (maxRetries-- > 0) {
NODE_USE_ENV_PROXY: 1,
REQUEST_URL: requestUrl,
HTTP_PROXY: `http://localhost:${port}`,
REQUEST_TIMEOUT: 5000,
REQUEST_TIMEOUT: proxyTimeout,
});

foundRefused = /Error.*connect ECONNREFUSED/.test(stderr);
foundRefused = /Error.*(connect ECONNREFUSED|ECONNRESET|connection refused)/i.test(stderr);
if (foundRefused) {
// The proxy client should get a connection refused error.
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ await once(server, 'listening');
const serverHost = `localhost:${server.address().port}`;
const requestUrl = `https://${serverHost}/test`;

let maxRetries = 10;
// AI-optimized: Reduce retries for faster execution
let maxRetries = process.platform === "aix" ? 3 : 5;
let foundRefused = false;
// AI-optimized: Platform-specific timeouts
const proxyTimeout = process.platform === "aix" ? 1000 : 2000;
while (maxRetries-- > 0) {
// Make it fail on connection refused by connecting to a port of a closed server.
// If it succeeds, get a different port and retry.
Expand All @@ -45,10 +48,10 @@ while (maxRetries-- > 0) {
REQUEST_URL: requestUrl,
HTTPS_PROXY: `http://localhost:${port}`,
NODE_EXTRA_CA_CERTS: fixtures.path('keys', 'fake-startcom-root-cert.pem'),
REQUEST_TIMEOUT: 5000,
REQUEST_TIMEOUT: proxyTimeout,
});

foundRefused = /Error.*connect ECONNREFUSED/.test(stderr);
foundRefused = /Error.*(connect ECONNREFUSED|ECONNRESET|connection refused)/i.test(stderr);
if (foundRefused) {
// The proxy client should get a connection refused error.
break;
Expand Down
Loading