-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: fix --abort-on-uncaught-exception
Revert 0af4c9e, parts of 921f2de and port nodejs/node-v0.x-archive#25835 from v0.12 to master so that node aborts at the right time when an error is thrown and --abort-on-uncaught-exception is used. Fixes #3035. PR: #3036 PR-URL: #3036 Reviewed-By: Ben Noordhuis <ben@strongloop.com>
- Loading branch information
1 parent
8b50e95
commit 546e833
Showing
8 changed files
with
363 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
test/parallel/test-domain-top-level-error-handler-throw.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict'; | ||
|
||
/* | ||
* The goal of this test is to make sure that when a top-level error | ||
* handler throws an error following the handling of a previous error, | ||
* the process reports the error message from the error thrown in the | ||
* top-level error handler, not the one from the previous error. | ||
*/ | ||
|
||
const common = require('../common'); | ||
|
||
const domainErrHandlerExMessage = 'exception from domain error handler'; | ||
const internalExMessage = 'You should NOT see me'; | ||
|
||
if (process.argv[2] === 'child') { | ||
var domain = require('domain'); | ||
var d = domain.create(); | ||
|
||
d.on('error', function() { | ||
throw new Error(domainErrHandlerExMessage); | ||
}); | ||
|
||
d.run(function doStuff() { | ||
process.nextTick(function() { | ||
throw new Error(internalExMessage); | ||
}); | ||
}); | ||
} else { | ||
var fork = require('child_process').fork; | ||
var assert = require('assert'); | ||
|
||
var child = fork(process.argv[1], ['child'], {silent:true}); | ||
var stderrOutput = ''; | ||
if (child) { | ||
child.stderr.on('data', function onStderrData(data) { | ||
stderrOutput += data.toString(); | ||
}); | ||
|
||
child.on('exit', function onChildExited(exitCode, signal) { | ||
assert(stderrOutput.indexOf(domainErrHandlerExMessage) !== -1); | ||
assert(stderrOutput.indexOf(internalExMessage) === -1); | ||
|
||
var expectedExitCode = 7; | ||
var expectedSignal = null; | ||
|
||
assert.equal(exitCode, expectedExitCode); | ||
assert.equal(signal, expectedSignal); | ||
}); | ||
} | ||
} |
Oops, something went wrong.