summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeokjin Kim <deokjin81.kim@gmail.com>2023-03-11 00:07:55 +0900
committerMichaël Zasso <targos@protonmail.com>2023-03-14 07:54:11 +0100
commit40a7b0b993f0331b10f268c7686d02f2a00c2625 (patch)
treeaa08ae4a38e8c8a84121662b55973106ebc00562
parente754277a4414d03dfce3dfb8494645627861437d (diff)
downloadnode-new-40a7b0b993f0331b10f268c7686d02f2a00c2625.tar.gz
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: https://github.com/nodejs/node/pull/47012 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
-rw-r--r--doc/api/net.md2
-rw-r--r--lib/net.js2
-rw-r--r--test/parallel/test-net-socket-connect-invalid-autoselectfamilyattempttimeout.js7
3 files changed, 9 insertions, 2 deletions
diff --git a/doc/api/net.md b/doc/api/net.md
index e7ec8f66f5..3ea7dff624 100644
--- a/doc/api/net.md
+++ b/doc/api/net.md
@@ -1659,7 +1659,7 @@ added: REPLACEME
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)`
diff --git a/lib/net.js b/lib/net.js
index 9644e6ef2e..3a4ff00561 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -247,7 +247,7 @@ function getDefaultAutoSelectFamilyAttemptTimeout() {
function setDefaultAutoSelectFamilyAttemptTimeout(value) {
validateInt32(value, 'value', 1);
- if (value < 1) {
+ if (value < 10) {
value = 10;
}
diff --git a/test/parallel/test-net-socket-connect-invalid-autoselectfamilyattempttimeout.js b/test/parallel/test-net-socket-connect-invalid-autoselectfamilyattempttimeout.js
index adec8200f6..0fc813781c 100644
--- a/test/parallel/test-net-socket-connect-invalid-autoselectfamilyattempttimeout.js
+++ b/test/parallel/test-net-socket-connect-invalid-autoselectfamilyattempttimeout.js
@@ -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);
+}