File tree 1 file changed +16
-2
lines changed
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 3
3
4
4
const common = require ( '../common' ) ;
5
5
const assert = require ( 'assert' ) ;
6
+ const util = require ( 'util' ) ;
6
7
const { MessageChannel } = require ( 'worker_threads' ) ;
7
8
8
9
const { port1, port2 } = new MessageChannel ( ) ;
@@ -25,9 +26,22 @@ assert.throws(common.mustCall(() => {
25
26
// The failed transfer should not affect the ports in anyway.
26
27
port2 . onmessage = common . mustCall ( ( message ) => {
27
28
assert . strictEqual ( message , 2 ) ;
29
+
30
+ assert ( util . inspect ( port1 ) . includes ( 'active: true' ) , util . inspect ( port1 ) ) ;
31
+ assert ( util . inspect ( port2 ) . includes ( 'active: true' ) , util . inspect ( port2 ) ) ;
32
+
28
33
port1 . close ( ) ;
29
34
30
- setTimeout ( common . mustNotCall ( 'The communication channel is still open' ) ,
31
- common . platformTimeout ( 1000 ) ) . unref ( ) ;
35
+ tick ( 10 , ( ) => {
36
+ assert ( util . inspect ( port1 ) . includes ( 'active: false' ) , util . inspect ( port1 ) ) ;
37
+ assert ( util . inspect ( port2 ) . includes ( 'active: false' ) , util . inspect ( port2 ) ) ;
38
+ } ) ;
32
39
} ) ;
33
40
port1 . postMessage ( 2 ) ;
41
+
42
+ function tick ( n , cb ) {
43
+ if ( n > 0 )
44
+ setImmediate ( ( ) => tick ( n - 1 , cb ) ) ;
45
+ else
46
+ cb ( ) ;
47
+ }
You can’t perform that action at this time.
0 commit comments