Skip to content

Commit 40a7b0b

Browse files
deokjinkimtargos
authored andcommitted
net: fix setting of value in 'setDefaultAutoSelectFamilyAttemptTimeout'
Document describes that the value have to be 10 if passed value to `setDefaultAutoSelectFamilyAttemptTimeout` is less than 10. So need to use 10 for 'if' statement and fix typo in document. Refs: https://github.com/nodejs/node/blob/main/doc/api/net.md#netsetdefaultautoselectfamilyattempttimeoutvalue PR-URL: #47012 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
1 parent e754277 commit 40a7b0b

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

doc/api/net.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ added: REPLACEME
16591659
Sets the default value of the `autoSelectFamilyAttemptTimeout` option of [`socket.connect(options)`][].
16601660

16611661
* `value` {number} The new default value, which must be a positive number. If the number is less than `10`,
1662-
the value `10` is used insted The initial default value is `250`.
1662+
the value `10` is used instead. The initial default value is `250`.
16631663

16641664
## `net.isIP(input)`
16651665

lib/net.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ function getDefaultAutoSelectFamilyAttemptTimeout() {
247247
function setDefaultAutoSelectFamilyAttemptTimeout(value) {
248248
validateInt32(value, 'value', 1);
249249

250-
if (value < 1) {
250+
if (value < 10) {
251251
value = 10;
252252
}
253253

test/parallel/test-net-socket-connect-invalid-autoselectfamilyattempttimeout.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ for (const autoSelectFamilyAttemptTimeout of [-10, 0]) {
1818
net.setDefaultAutoSelectFamilyAttemptTimeout(autoSelectFamilyAttemptTimeout);
1919
}, { code: 'ERR_OUT_OF_RANGE' });
2020
}
21+
22+
// Check the default value of autoSelectFamilyAttemptTimeout is 10
23+
// if passed number is less than 10
24+
for (const autoSelectFamilyAttemptTimeout of [1, 9]) {
25+
net.setDefaultAutoSelectFamilyAttemptTimeout(autoSelectFamilyAttemptTimeout);
26+
assert.strictEqual(net.getDefaultAutoSelectFamilyAttemptTimeout(), 10);
27+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy