@@ -37,10 +37,8 @@ const SENTINEL = 42;
37
37
// 3 disconnect worker with child_process's disconnect, confirm
38
38
// no sentinel value
39
39
if ( cluster . isWorker ) {
40
- process . on ( 'disconnect' , function ( msg ) {
41
- setTimeout ( function ( ) {
42
- process . exit ( SENTINEL ) ;
43
- } , 10 ) ;
40
+ process . on ( 'disconnect' , ( msg ) => {
41
+ setTimeout ( ( ) => process . exit ( SENTINEL ) , 10 ) ;
44
42
} ) ;
45
43
return ;
46
44
}
@@ -49,17 +47,17 @@ checkUnforced();
49
47
checkForced ( ) ;
50
48
51
49
function checkUnforced ( ) {
52
- cluster . fork ( )
53
- . on ( 'online' , function ( ) { this . disconnect ( ) ; } )
54
- . on ( 'exit' , common . mustCall ( function ( status ) {
50
+ const worker = cluster . fork ( ) ;
51
+ worker
52
+ . on ( 'online' , common . mustCall ( ( ) => worker . disconnect ( ) ) )
53
+ . on ( 'exit' , common . mustCall ( ( status ) => {
55
54
assert . strictEqual ( status , SENTINEL ) ;
56
55
} ) ) ;
57
56
}
58
57
59
58
function checkForced ( ) {
60
- cluster . fork ( )
61
- . on ( 'online' , function ( ) { this . process . disconnect ( ) ; } )
62
- . on ( 'exit' , common . mustCall ( function ( status ) {
63
- assert . strictEqual ( status , 0 ) ;
64
- } ) ) ;
59
+ const worker = cluster . fork ( ) ;
60
+ worker
61
+ . on ( 'online' , common . mustCall ( ( ) => worker . process . disconnect ( ) ) )
62
+ . on ( 'exit' , common . mustCall ( ( status ) => assert . strictEqual ( status , 0 ) ) ) ;
65
63
}
0 commit comments