Skip to content

Commit 67fe7d8

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 24d3fcf commit 67fe7d8

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

doc/api/net.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ added: v18.18.0
16701670
Sets the default value of the `autoSelectFamilyAttemptTimeout` option of [`socket.connect(options)`][].
16711671

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

16751675
## `net.isIP(input)`
16761676

lib/net.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ function getDefaultAutoSelectFamilyAttemptTimeout() {
265265
function setDefaultAutoSelectFamilyAttemptTimeout(value) {
266266
validateInt32(value, 'value', 1);
267267

268-
if (value < 1) {
268+
if (value < 10) {
269269
value = 10;
270270
}
271271

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

+7
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)