Skip to content

Commit

Permalink
Revert "async_hooks: only set up hooks if used"
Browse files Browse the repository at this point in the history
This reverts commit 410b141.

PR-URL: #13509
Reviewed-By: Andreas Madsen <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
trevnorris authored and addaleax committed Jul 11, 2017
1 parent a442603 commit 8b57b09
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ const before_symbol = Symbol('before');
const after_symbol = Symbol('after');
const destroy_symbol = Symbol('destroy');

let setupHooksCalled = false;
// Setup the callbacks that node::AsyncWrap will call when there are hooks to
// process. They use the same functions as the JS embedder API.
async_wrap.setupHooks({ init,
before: emitBeforeN,
after: emitAfterN,
destroy: emitDestroyN });

// Used to fatally abort the process if a callback throws.
function fatalError(e) {
Expand Down Expand Up @@ -98,16 +103,6 @@ class AsyncHook {
if (hooks_array.includes(this))
return this;

if (!setupHooksCalled) {
setupHooksCalled = true;
// Setup the callbacks that node::AsyncWrap will call when there are
// hooks to process. They use the same functions as the JS embedder API.
async_wrap.setupHooks({ init,
before: emitBeforeN,
after: emitAfterN,
destroy: emitDestroyN });
}

// createHook() has already enforced that the callbacks are all functions,
// so here simply increment the count of whether each callbacks exists or
// not.
Expand Down

0 comments on commit 8b57b09

Please sign in to comment.