Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
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
11 changes: 11 additions & 0 deletions 11 doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,15 @@ added: v7.10.0

This option is a no-op. It is kept for compatibility.

### `--network-family-autoselection-attempt-timeout`

<!-- YAML
added: REPLACEME
-->

Sets the default value for the network family autoselection attempt timeout.
For more information, see [`net.getDefaultAutoSelectFamilyAttemptTimeout()`][].

### `--no-addons`

<!-- YAML
Expand Down Expand Up @@ -2635,6 +2644,7 @@ one is included in the list below.
* `--inspect`
* `--max-http-header-size`
* `--napi-modules`
* `--network-family-autoselection-attempt-timeout`
* `--no-addons`
* `--no-deprecation`
* `--no-experimental-fetch`
Expand Down Expand Up @@ -3161,6 +3171,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
[`dns.setDefaultResultOrder()`]: dns.md#dnssetdefaultresultorderorder
[`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options
[`import` specifier]: esm.md#import-specifiers
[`net.getDefaultAutoSelectFamilyAttemptTimeout()`]: net.md#netgetdefaultautoselectfamilyattempttimeout
[`process.setUncaughtExceptionCaptureCallback()`]: process.md#processsetuncaughtexceptioncapturecallbackfn
[`process.setuid()`]: process.md#processsetuidid
[`setuid(2)`]: https://man7.org/linux/man-pages/man2/setuid.2.html
Expand Down
6 changes: 4 additions & 2 deletions 6 doc/api/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,8 @@ added:
-->

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

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

Expand All @@ -1763,7 +1764,8 @@ added:
Sets the default value of the `autoSelectFamilyAttemptTimeout` option of [`socket.connect(options)`][].

* `value` {number} The new default value, which must be a positive number. If the number is less than `10`,
the value `10` is used instead. The initial default value is `250`.
the value `10` is used instead. The initial default value is `250` or the value specified via the command line
option `--network-family-autoselection-attempt-timeout`.

## `net.isIP(input)`

Expand Down
2 changes: 1 addition & 1 deletion 2 lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ let dns;
let BlockList;
let SocketAddress;
let autoSelectFamilyDefault = getOptionValue('--network-family-autoselection');
let autoSelectFamilyAttemptTimeoutDefault = 250;
let autoSelectFamilyAttemptTimeoutDefault = getOptionValue('--network-family-autoselection-attempt-timeout');

const { clearTimeout, setTimeout } = require('timers');
const { kTimeout } = require('internal/timers');
Expand Down
5 changes: 5 additions & 0 deletions 5 src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
&EnvironmentOptions::network_family_autoselection,
kAllowedInEnvvar,
true);
AddOption("--network-family-autoselection-attempt-timeout",
"Sets the default value for the network family autoselection "
"attempt timeout.",
&EnvironmentOptions::network_family_autoselection_attempt_timeout,
kAllowedInEnvvar);
AddAlias("--enable-network-family-autoselection",
"--network-family-autoselection");
AddOption("--enable-source-maps",
Expand Down
1 change: 1 addition & 0 deletions 1 src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class EnvironmentOptions : public Options {
int64_t heap_snapshot_near_heap_limit = 0;
std::string heap_snapshot_signal;
bool network_family_autoselection = true;
uint64_t network_family_autoselection_attempt_timeout = 250;
uint64_t max_http_header_size = 16 * 1024;
bool deprecation = true;
bool force_async_hooks_checks = true;
Expand Down
8 changes: 2 additions & 6 deletions 8 test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,8 @@ const isPi = (() => {
const isDumbTerminal = process.env.TERM === 'dumb';

// When using high concurrency or in the CI we need much more time for each connection attempt
const defaultAutoSelectFamilyAttemptTimeout = platformTimeout(2500);
// Since this is also used by tools outside of the test suite,
// make sure setDefaultAutoSelectFamilyAttemptTimeout
if (typeof net.setDefaultAutoSelectFamilyAttemptTimeout === 'function') {
net.setDefaultAutoSelectFamilyAttemptTimeout(platformTimeout(defaultAutoSelectFamilyAttemptTimeout));
}
net.setDefaultAutoSelectFamilyAttemptTimeout(platformTimeout(net.getDefaultAutoSelectFamilyAttemptTimeout() * 10));
const defaultAutoSelectFamilyAttemptTimeout = net.getDefaultAutoSelectFamilyAttemptTimeout();

const buildType = process.config.target_defaults ?
process.config.target_defaults.default_configuration :
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

// Flags: --network-family-autoselection-attempt-timeout=123

const { platformTimeout } = require('../common');

const assert = require('assert');
const { getDefaultAutoSelectFamilyAttemptTimeout } = require('net');

assert.strictEqual(getDefaultAutoSelectFamilyAttemptTimeout(), platformTimeout(123 * 10));
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

const { platformTimeout } = require('../common');

const assert = require('assert');
const { getDefaultAutoSelectFamilyAttemptTimeout } = require('net');

assert.strictEqual(getDefaultAutoSelectFamilyAttemptTimeout(), platformTimeout(2500));
Morty Proxy This is a proxified and sanitized view of the page, visit original site.