-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: finish assigning codes to errors thrown from JS #19373
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -387,6 +387,7 @@ function writeAfterFIN(chunk, encoding, cb) { | |
encoding = null; | ||
} | ||
|
||
// eslint-disable-next-line no-restricted-syntax | ||
var er = new Error('This socket has been ended by the other party'); | ||
er.code = 'EPIPE'; | ||
// TODO: defer error events consistently everywhere, not just the cb | ||
|
@@ -935,7 +936,7 @@ function internalConnect( | |
localAddress = localAddress || '::'; | ||
err = self._handle.bind6(localAddress, localPort); | ||
} else { | ||
self.destroy(new TypeError('Invalid addressType: ' + addressType)); | ||
self.destroy(new ERR_INVALID_ADDRESS_FAMILY(addressType)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is unreachable now, so I removed the test. I'm going to replace it by a CHECK when #19503 is fixed. |
||
return; | ||
} | ||
debug('binding to localAddress: %s and localPort: %d (addressType: %d)', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,6 +207,7 @@ function testRunnerMain() { | |
function masterProcessMain() { | ||
const workers = JSON.parse(process.env.workers); | ||
const clusterSettings = JSON.parse(process.env.clusterSettings); | ||
const badPortError = { type: RangeError, code: 'ERR_SOCKET_BAD_PORT' }; | ||
let debugPort = process.debugPort; | ||
|
||
for (const worker of workers) { | ||
|
@@ -234,36 +235,36 @@ function masterProcessMain() { | |
clusterSettings.inspectPort = 'string'; | ||
cluster.setupMaster(clusterSettings); | ||
|
||
assert.throws(() => { | ||
common.expectsError(() => { | ||
cluster.fork(params).on('exit', common.mustCall(checkExitCode)); | ||
}, TypeError); | ||
}, badPortError); | ||
|
||
return; | ||
} else if (clusterSettings.inspectPort === 'null') { | ||
clusterSettings.inspectPort = null; | ||
cluster.setupMaster(clusterSettings); | ||
|
||
assert.throws(() => { | ||
common.expectsError(() => { | ||
cluster.fork(params).on('exit', common.mustCall(checkExitCode)); | ||
}, TypeError); | ||
}, badPortError); | ||
|
||
return; | ||
} else if (clusterSettings.inspectPort === 'bignumber') { | ||
clusterSettings.inspectPort = 1293812; | ||
cluster.setupMaster(clusterSettings); | ||
|
||
assert.throws(() => { | ||
common.expectsError(() => { | ||
cluster.fork(params).on('exit', common.mustCall(checkExitCode)); | ||
}, TypeError); | ||
}, badPortError); | ||
|
||
return; | ||
} else if (clusterSettings.inspectPort === 'negativenumber') { | ||
clusterSettings.inspectPort = -9776; | ||
cluster.setupMaster(clusterSettings); | ||
|
||
assert.throws(() => { | ||
common.expectsError(() => { | ||
cluster.fork(params).on('exit', common.mustCall(checkExitCode)); | ||
}, TypeError); | ||
}, badPortError); | ||
|
||
return; | ||
} else if (clusterSettings.inspectPort === 'bignumberfunc') { | ||
|
@@ -274,9 +275,9 @@ function masterProcessMain() { | |
|
||
cluster.setupMaster(clusterSettings); | ||
|
||
assert.throws(() => { | ||
common.expectsError(() => { | ||
cluster.fork(params).on('exit', common.mustCall(checkExitCode)); | ||
}, TypeError); | ||
}, badPortError); | ||
|
||
return; | ||
} else if (clusterSettings.inspectPort === 'strfunc') { | ||
|
@@ -287,9 +288,9 @@ function masterProcessMain() { | |
|
||
cluster.setupMaster(clusterSettings); | ||
|
||
assert.throws(() => { | ||
common.expectsError(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a recommendation for the future: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What should I do to make it work with This is what I get:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now there are some special handled properties in |
||
cluster.fork(params).on('exit', common.mustCall(checkExitCode)); | ||
}, TypeError); | ||
}, badPortError); | ||
|
||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we now check for
kMaxLength
: is it still possible for the alloc to throw an error? If not, then thetry / catch
should be obsolete.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can still throw if there is not enough memory available to construct the buffer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, I thought it might crash in that case but it will actually throw
Array buffer allocation failed
.