Skip to content

Commit

Permalink
net: fix setting of value in
Browse files Browse the repository at this point in the history
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: nodejs/node#47012
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
  • Loading branch information
sercher committed Apr 24, 2024
1 parent bf4207c commit 3c7820f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion graal-nodejs/doc/api/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ added: v18.18.0
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 insted The initial default value is `250`.
the value `10` is used instead. The initial default value is `250`.

## `net.isIP(input)`

Expand Down
2 changes: 1 addition & 1 deletion graal-nodejs/lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function getDefaultAutoSelectFamilyAttemptTimeout() {
function setDefaultAutoSelectFamilyAttemptTimeout(value) {
validateInt32(value, 'value', 1);

if (value < 1) {
if (value < 10) {
value = 10;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ for (const autoSelectFamilyAttemptTimeout of [-10, 0]) {
net.setDefaultAutoSelectFamilyAttemptTimeout(autoSelectFamilyAttemptTimeout);
}, { code: 'ERR_OUT_OF_RANGE' });
}

// Check the default value of autoSelectFamilyAttemptTimeout is 10
// if passed number is less than 10
for (const autoSelectFamilyAttemptTimeout of [1, 9]) {
net.setDefaultAutoSelectFamilyAttemptTimeout(autoSelectFamilyAttemptTimeout);
assert.strictEqual(net.getDefaultAutoSelectFamilyAttemptTimeout(), 10);
}

0 comments on commit 3c7820f

Please sign in to comment.