File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -544,8 +544,8 @@ function getTimerCallbacks(runNextTicks) {
544
544
545
545
if ( destroyHooksExist ( ) && ! timer . _destroyed ) {
546
546
emitDestroy ( timer [ async_id_symbol ] ) ;
547
- timer . _destroyed = true ;
548
547
}
548
+ timer . _destroyed = true ;
549
549
}
550
550
}
551
551
Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ function unenroll(item) {
65
65
item [ async_id_symbol ] !== undefined &&
66
66
! item . _destroyed ) {
67
67
emitDestroy ( item [ async_id_symbol ] ) ;
68
- item . _destroyed = true ;
69
68
}
69
+ item . _destroyed = true ;
70
70
71
71
L . remove ( item ) ;
72
72
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common' ) ;
4
+ const assert = require ( 'assert' ) ;
5
+
6
+ // We don't really care about the calling results here.
7
+ // So, this makes the test less fragile.
8
+ const noop = ( ) => { } ;
9
+
10
+ const t1 = setTimeout ( common . mustNotCall ( ) , 1 ) ;
11
+ const t2 = setTimeout ( common . mustCall ( ) , 1 ) ;
12
+ const i1 = setInterval ( common . mustNotCall ( ) , 1 ) ;
13
+ const i2 = setInterval ( noop , 1 ) ;
14
+ i2 . unref ( ) ;
15
+
16
+ // Keep process alive for i2 to call once due to timer ordering.
17
+ setTimeout ( common . mustCall ( ) , 1 ) ;
18
+
19
+ clearTimeout ( t1 ) ;
20
+ clearInterval ( i1 ) ;
21
+
22
+ process . on ( 'exit' , ( ) => {
23
+ assert . strictEqual ( t1 . _destroyed , true ) ;
24
+ assert . strictEqual ( t2 . _destroyed , true ) ;
25
+ assert . strictEqual ( i1 . _destroyed , true ) ;
26
+ assert . strictEqual ( i2 . _destroyed , false ) ;
27
+ } ) ;
You can’t perform that action at this time.
0 commit comments