Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 506b79e

Browse files
rvaggaduh95
authored andcommitted
net: increase network family autoselection timeout to 500ms
The current 250ms timeout is too short for high-latency network environments, causing connection failures in IPv4-only networks when connecting to dual-stack hosts. This increases the timeout to 500ms to better handle satellite, cellular, and geographically distant connections. The timeout should be reconsidered when parallel connections are implemented as per RFC 8305. Refs: #54359 Refs: #48145 PR-URL: #60334 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Tim Perry <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Juan JosΓ© Arboleda <[email protected]> Reviewed-By: Ulises GascΓ³n <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent ae91a6c commit 506b79e

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

β€Ždoc/api/net.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,7 @@ added:
19051905
-->
19061906

19071907
Gets the current default value of the `autoSelectFamilyAttemptTimeout` option of [`socket.connect(options)`][].
1908-
The initial default value is `250` or the value specified via the command line
1908+
The initial default value is `500` or the value specified via the command line
19091909
option `--network-family-autoselection-attempt-timeout`.
19101910

19111911
* Returns: {number} The current default value of the `autoSelectFamilyAttemptTimeout` option.

β€Žsrc/node_options.hβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class EnvironmentOptions : public Options {
155155
int64_t heap_snapshot_near_heap_limit = 0;
156156
std::string heap_snapshot_signal;
157157
bool network_family_autoselection = true;
158-
uint64_t network_family_autoselection_attempt_timeout = 250;
158+
uint64_t network_family_autoselection_attempt_timeout = 500;
159159
uint64_t max_http_header_size = 16 * 1024;
160160
bool deprecation = true;
161161
bool force_async_hooks_checks = true;

β€Žtest/common/index.jsβ€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ function isPi() {
184184
}
185185
}
186186

187-
// When using high concurrency or in the CI we need much more time for each connection attempt
188-
net.setDefaultAutoSelectFamilyAttemptTimeout(platformTimeout(net.getDefaultAutoSelectFamilyAttemptTimeout() * 10));
187+
// When using high concurrency or in the CI we need much more time for each connection attempt.
188+
// Default 500ms becomes 2500ms for tests.
189+
net.setDefaultAutoSelectFamilyAttemptTimeout(platformTimeout(net.getDefaultAutoSelectFamilyAttemptTimeout() * 5));
189190
const defaultAutoSelectFamilyAttemptTimeout = net.getDefaultAutoSelectFamilyAttemptTimeout();
190191

191192
const buildType = process.config.target_defaults ?

β€Žtest/parallel/test-net-autoselectfamily-attempt-timeout-cli-option.jsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ const { platformTimeout } = require('../common');
77
const assert = require('assert');
88
const { getDefaultAutoSelectFamilyAttemptTimeout } = require('net');
99

10-
assert.strictEqual(getDefaultAutoSelectFamilyAttemptTimeout(), platformTimeout(123 * 10));
10+
assert.strictEqual(getDefaultAutoSelectFamilyAttemptTimeout(), platformTimeout(123 * 5));

0 commit comments

Comments
Β (0)