Skip to content

Commit

Permalink
errors: fix ERR_SOCKET_BAD_PORT message
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Gioyik authored and targos committed Sep 27, 2018
1 parent 2b7e18d commit d9d9d23
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ An invalid (negative) size was passed for either the `recvBufferSize` or
<a id="ERR_SOCKET_BAD_PORT"></a>
### ERR_SOCKET_BAD_PORT

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

<a id="ERR_SOCKET_BAD_TYPE"></a>
### ERR_SOCKET_BAD_TYPE
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ E('ERR_SOCKET_ALREADY_BOUND', 'Socket is already bound', Error);
E('ERR_SOCKET_BAD_BUFFER_SIZE',
'Buffer size must be a positive integer', TypeError);
E('ERR_SOCKET_BAD_PORT',
'Port should be > 0 and < 65536. Received %s.', RangeError);
'Port should be >= 0 and < 65536. Received %s.', RangeError);
E('ERR_SOCKET_BAD_TYPE',
'Bad socket type specified. Valid types are: udp4, udp6', TypeError);
E('ERR_SOCKET_BUFFER_SIZE',
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const portErr = (port) => {
const err = {
code: 'ERR_SOCKET_BAD_PORT',
message:
`Port should be > 0 and < 65536. Received ${port}.`,
`Port should be >= 0 and < 65536. Received ${port}.`,
type: RangeError
};

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-internal-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ assert.strictEqual(errors.getMessage('ERR_MISSING_ARGS', ['a', 'b', 'c']),
// Test ERR_SOCKET_BAD_PORT
assert.strictEqual(
errors.getMessage('ERR_SOCKET_BAD_PORT', [0]),
'Port should be > 0 and < 65536. Received 0.');
'Port should be >= 0 and < 65536. Received 0.');

// Test ERR_TLS_CERT_ALTNAME_INVALID
assert.strictEqual(
Expand Down

0 comments on commit d9d9d23

Please sign in to comment.