From 3b773d7f61f0a805d027cd5606383564d5f5ebea Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Tue, 6 Jun 2017 10:50:36 -0600 Subject: [PATCH] Revert "async_hooks: only set up hooks if used" This reverts commit 410b1417648b5273fe80f4d910c6bbd198a00a2d. PR-URL: https://github.com/nodejs/node/pull/13509 Reviewed-By: Andreas Madsen Reviewed-By: Anna Henningsen --- lib/async_hooks.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/async_hooks.js b/lib/async_hooks.js index 1726a4f7e1dfea..9fac1e506ba06d 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -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) { @@ -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.