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.
domains: clear stack when no error handler
Clear domains stack __even if no domain error handler is set__ so that code running in the process' uncaughtException handler, or any code that may be executed when an error is thrown and not caught and that is not the domain's error handler, doesn't run in the context of the domain within which the error was thrown. PR: nodejs#4659 PR-URL: nodejs#4659 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
- Loading branch information
Julien Gilli
authored and
Michael Scovetta
committed
Apr 2, 2016
1 parent
bb93fd6
commit 6ab8452
Showing
2 changed files
with
31 additions
and
15 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
22 changes: 22 additions & 0 deletions
22
test/parallel/test-domain-stack-empty-in-process-uncaughtexception.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,22 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const domain = require('domain'); | ||
const assert = require('assert'); | ||
|
||
const d = domain.create(); | ||
|
||
process.on('uncaughtException', common.mustCall(function onUncaught() { | ||
assert.equal(process.domain, null, | ||
'domains stack should be empty in uncaughtException handler'); | ||
})); | ||
|
||
process.on('beforeExit', common.mustCall(function onBeforeExit() { | ||
assert.equal(process.domain, null, | ||
'domains stack should be empty in beforeExit handler'); | ||
})); | ||
|
||
d.run(function() { | ||
throw new Error('boom'); | ||
}); | ||
|