@@ -89,28 +89,30 @@ describe('idle timeout', () => {
89
89
90
90
it ( 'unrefs the connections and timeouts so the program can exit when idle when the allowExitOnIdle option is set' , function ( done ) {
91
91
const child = fork ( path . join ( __dirname , 'idle-timeout-exit.js' ) , [ ] , {
92
- silent : true ,
92
+ stdio : [ 'ignore' , 'pipe' , 'inherit' , 'ipc' ] ,
93
93
env : { ...process . env , ALLOW_EXIT_ON_IDLE : '1' } ,
94
94
} )
95
95
let result = ''
96
96
child . stdout . setEncoding ( 'utf8' )
97
97
child . stdout . on ( 'data' , ( chunk ) => ( result += chunk ) )
98
98
child . on ( 'error' , ( err ) => done ( err ) )
99
- child . on ( 'close' , ( ) => {
99
+ child . on ( 'exit' , ( exitCode ) => {
100
+ expect ( exitCode ) . to . equal ( 0 )
100
101
expect ( result ) . to . equal ( 'completed first\ncompleted second\n' )
101
102
done ( )
102
103
} )
103
104
} )
104
105
105
106
it ( 'keeps old behavior when allowExitOnIdle option is not set' , function ( done ) {
106
107
const child = fork ( path . join ( __dirname , 'idle-timeout-exit.js' ) , [ ] , {
107
- silent : true ,
108
+ stdio : [ 'ignore' , 'pipe' , 'inherit' , 'ipc' ] ,
108
109
} )
109
110
let result = ''
110
111
child . stdout . setEncoding ( 'utf8' )
111
112
child . stdout . on ( 'data' , ( chunk ) => ( result += chunk ) )
112
113
child . on ( 'error' , ( err ) => done ( err ) )
113
- child . on ( 'close' , ( ) => {
114
+ child . on ( 'exit' , ( exitCode ) => {
115
+ expect ( exitCode ) . to . equal ( 0 )
114
116
expect ( result ) . to . equal ( 'completed first\ncompleted second\nremoved\n' )
115
117
done ( )
116
118
} )
0 commit comments