forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
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 nodejs#3035. PR: nodejs#3036 PR-URL: nodejs#3036 Reviewed-By: Ben Noordhuis <[email protected]>
- Loading branch information
1 parent
49dec1a
commit 77a10ed
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.