Skip to content
Browse files

test: print resource stack on error

When running tests with NODE_TEST_WITH_ASYNC_HOOKS and the same asyncId
is detected twice print the stack traces of both init() calls. Also
print if the resource is the same instance.

PR-URL: #14208
Reviewed-By: James M Snell <>
Reviewed-By: Refael Ackermann <>
  • Loading branch information
trevnorris authored and MylesBorins committed Jun 16, 2017
1 parent 81515c7 commit 98fc6659406e9fadeb30498b7bc3378a8d62eaee
Showing with 6 additions and 3 deletions.
  1. +6 −3 test/common/index.js
@@ -79,18 +79,21 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
if (destroyListList[id] !== undefined) {
throw new Error(`same id added twice (${id})`);
throw new Error(`same id added to destroy list twice (${id})`);
destroyListList[id] = new Error().stack;

init(id, ty, tr, h) {
init(id, ty, tr, r) {
if (initHandles[id]) {
`Is same resource: ${r === initHandles[id].resource}`);
process._rawDebug(`Previous stack:\n${initHandles[id].stack}\n`);
throw new Error(`init called twice for same id (${id})`);
initHandles[id] = h;
initHandles[id] = { resource: r, stack: new Error().stack.substr(6) };
before() { },
after() { },

0 comments on commit 98fc665

Please sign in to comment.
You can’t perform that action at this time.