This repository has been archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge a80b162 as of 2017-08-30. This is an automatically created merge. For any problems please contact @kunalspathak.
- Loading branch information
Showing
13 changed files
with
103 additions
and
19 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const async_hooks = require('async_hooks'); | ||
|
||
const id_obj = {}; | ||
let collect = true; | ||
|
||
const hook = async_hooks.createHook({ | ||
before(id) { if (collect) id_obj[id] = true; }, | ||
after(id) { delete id_obj[id]; }, | ||
}).enable(); | ||
|
||
process.once('uncaughtException', common.mustCall((er) => { | ||
assert.strictEqual(er.message, 'bye'); | ||
collect = false; | ||
})); | ||
|
||
setImmediate(common.mustCall(() => { | ||
process.nextTick(common.mustCall(() => { | ||
assert.strictEqual(Object.keys(id_obj).length, 0); | ||
hook.disable(); | ||
})); | ||
|
||
// Create a stack of async ids that will need to be emitted in the case of | ||
// an uncaught exception. | ||
const ar1 = new async_hooks.AsyncResource('Mine'); | ||
ar1.emitBefore(); | ||
|
||
const ar2 = new async_hooks.AsyncResource('Mine'); | ||
ar2.emitBefore(); | ||
|
||
throw new Error('bye'); | ||
|
||
// TODO(trevnorris): This test shows that the after() hooks are always called | ||
// correctly, but it doesn't solve where the emitDestroy() is missed because | ||
// of the uncaught exception. Simple solution is to always call emitDestroy() | ||
// before the emitAfter(), but how to codify this? | ||
})); |
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