File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ class AsyncHook {
9696
9797 // Each hook is only allowed to be added once.
9898 if ( hooks_array . includes ( this ) )
99- return ;
99+ return this ;
100100
101101 if ( ! setupHooksCalled ) {
102102 setupHooksCalled = true ;
@@ -124,7 +124,7 @@ class AsyncHook {
124124
125125 const index = hooks_array . indexOf ( this ) ;
126126 if ( index === - 1 )
127- return ;
127+ return this ;
128128
129129 hook_fields [ kInit ] -= + ! ! this [ init_symbol ] ;
130130 hook_fields [ kBefore ] -= + ! ! this [ before_symbol ] ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../common' ) ;
3+ const assert = require ( 'assert' ) ;
4+ const async_hooks = require ( 'async_hooks' ) ;
5+
6+ const hook = async_hooks . createHook ( {
7+ init : common . mustCall ( ( ) => { } , 1 ) ,
8+ before : common . mustNotCall ( ) ,
9+ after : common . mustNotCall ( ) ,
10+ destroy : common . mustNotCall ( )
11+ } ) ;
12+
13+ assert . strictEqual ( hook . enable ( ) , hook ) ;
14+ assert . strictEqual ( hook . enable ( ) , hook ) ;
15+
16+ setImmediate ( common . mustCall ( ) ) ;
17+
18+ assert . strictEqual ( hook . disable ( ) , hook ) ;
19+ assert . strictEqual ( hook . disable ( ) , hook ) ;
20+ assert . strictEqual ( hook . disable ( ) , hook ) ;
You can’t perform that action at this time.
0 commit comments