File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -49,12 +49,7 @@ const before_symbol = Symbol('before');
49
49
const after_symbol = Symbol ( 'after' ) ;
50
50
const destroy_symbol = Symbol ( 'destroy' ) ;
51
51
52
- // Setup the callbacks that node::AsyncWrap will call when there are hooks to
53
- // process. They use the same functions as the JS embedder API.
54
- async_wrap . setupHooks ( { init,
55
- before : emitBeforeN ,
56
- after : emitAfterN ,
57
- destroy : emitDestroyN } ) ;
52
+ let setupHooksCalled = false ;
58
53
59
54
// Used to fatally abort the process if a callback throws.
60
55
function fatalError ( e ) {
@@ -103,6 +98,16 @@ class AsyncHook {
103
98
if ( hooks_array . includes ( this ) )
104
99
return ;
105
100
101
+ if ( ! setupHooksCalled ) {
102
+ setupHooksCalled = true ;
103
+ // Setup the callbacks that node::AsyncWrap will call when there are
104
+ // hooks to process. They use the same functions as the JS embedder API.
105
+ async_wrap . setupHooks ( { init,
106
+ before : emitBeforeN ,
107
+ after : emitAfterN ,
108
+ destroy : emitDestroyN } ) ;
109
+ }
110
+
106
111
// createHook() has already enforced that the callbacks are all functions,
107
112
// so here simply increment the count of whether each callbacks exists or
108
113
// not.
You can’t perform that action at this time.
0 commit comments