Skip to content

Commit d9d9d23

Browse files
Gioyiktargos
authored andcommitted
errors: fix ERR_SOCKET_BAD_PORT message
The current message says 'Port should be > 0' meaning '0' is an invalid value. You can pass '0' to get a random port from the system. The correct message for this error is 'Port should be >= 0'. PR-URL: #23015 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 2b7e18d commit d9d9d23

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

doc/api/errors.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ An invalid (negative) size was passed for either the `recvBufferSize` or
15261526
<a id="ERR_SOCKET_BAD_PORT"></a>
15271527
### ERR_SOCKET_BAD_PORT
15281528

1529-
An API function expecting a port > 0 and < 65536 received an invalid value.
1529+
An API function expecting a port >= 0 and < 65536 received an invalid value.
15301530

15311531
<a id="ERR_SOCKET_BAD_TYPE"></a>
15321532
### ERR_SOCKET_BAD_TYPE

lib/internal/errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ E('ERR_SOCKET_ALREADY_BOUND', 'Socket is already bound', Error);
808808
E('ERR_SOCKET_BAD_BUFFER_SIZE',
809809
'Buffer size must be a positive integer', TypeError);
810810
E('ERR_SOCKET_BAD_PORT',
811-
'Port should be > 0 and < 65536. Received %s.', RangeError);
811+
'Port should be >= 0 and < 65536. Received %s.', RangeError);
812812
E('ERR_SOCKET_BAD_TYPE',
813813
'Bad socket type specified. Valid types are: udp4, udp6', TypeError);
814814
E('ERR_SOCKET_BUFFER_SIZE',

test/parallel/test-dns.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ const portErr = (port) => {
290290
const err = {
291291
code: 'ERR_SOCKET_BAD_PORT',
292292
message:
293-
`Port should be > 0 and < 65536. Received ${port}.`,
293+
`Port should be >= 0 and < 65536. Received ${port}.`,
294294
type: RangeError
295295
};
296296

test/parallel/test-internal-errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ assert.strictEqual(errors.getMessage('ERR_MISSING_ARGS', ['a', 'b', 'c']),
129129
// Test ERR_SOCKET_BAD_PORT
130130
assert.strictEqual(
131131
errors.getMessage('ERR_SOCKET_BAD_PORT', [0]),
132-
'Port should be > 0 and < 65536. Received 0.');
132+
'Port should be >= 0 and < 65536. Received 0.');
133133

134134
// Test ERR_TLS_CERT_ALTNAME_INVALID
135135
assert.strictEqual(

0 commit comments

Comments
 (0)