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 <matteo.collina@gmail.com> Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
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)