@@ -24,12 +24,14 @@ async function assertProcessGone(pid) {
2424
2525test ( 'grace timer does not retain the caller after the child exits' , async ( ) => {
2626 const moduleUrl = new URL ( '../scripts/lib/process.mjs' , import . meta. url ) . href ;
27- const source = `import { spawn } from 'node:child_process'; import { terminateProcess } from ${ JSON . stringify ( moduleUrl ) } ; const child=spawn(process.execPath,['-e','setInterval(()=>{},10000)']); await terminateProcess(child,{graceMs:1000});` ;
27+ const graceMs = process . platform === 'win32' ? 5_000 : 1_000 ;
28+ const source = `import { spawn } from 'node:child_process'; import { terminateProcess } from ${ JSON . stringify ( moduleUrl ) } ; const child=spawn(process.execPath,['-e','setInterval(()=>{},10000)']); await terminateProcess(child,{graceMs:${ graceMs } });` ;
2829 const started = Date . now ( ) ;
2930 const runner = spawn ( process . execPath , [ '--input-type=module' , '-e' , source ] , { stdio : 'ignore' } ) ;
3031 const code = await new Promise ( ( resolve ) => runner . once ( 'exit' , resolve ) ) ;
3132 assert . equal ( code , 0 ) ;
32- assert . ok ( Date . now ( ) - started < 700 , 'the cancelled grace timer must not keep the event loop alive' ) ;
33+ const budgetMs = process . platform === 'win32' ? 3_000 : 700 ;
34+ assert . ok ( Date . now ( ) - started < budgetMs , 'the cancelled grace timer must not keep the event loop alive' ) ;
3335} ) ;
3436
3537test ( 'runProcess fails closed on timeout and bounded output' , async ( ) => {
@@ -130,7 +132,7 @@ test('close aborts and detaches a never-settling permission task under strict re
130132 assert.equal(firstClose, secondClose);
131133 await firstClose;
132134 const elapsedMs = Date.now() - started;
133- assert.ok(elapsedMs <= 200, 'close took ' + elapsedMs + 'ms');
135+ assert.ok(elapsedMs <= (process.platform === 'win32' ? 2_000 : 200) , 'close took ' + elapsedMs + 'ms');
134136 await new Promise((resolve) => setImmediate(resolve));
135137 assert.ok(handlerSignals.every((signal) => signal.aborted));
136138 assert.equal(protocol.serverTasks.size, 0);
@@ -143,7 +145,7 @@ test('close aborts and detaches a never-settling permission task under strict re
143145 runner . stderr . setEncoding ( 'utf8' ) ; runner . stderr . on ( 'data' , ( chunk ) => { stderr += chunk ; } ) ;
144146 const outcome = await Promise . race ( [
145147 new Promise ( ( resolve ) => runner . once ( 'exit' , ( code , signal ) => resolve ( { code, signal } ) ) ) ,
146- new Promise ( ( resolve ) => { const timer = setTimeout ( ( ) => resolve ( { timeout : true } ) , 1_000 ) ; timer . unref ( ) ; } ) ,
148+ new Promise ( ( resolve ) => { const timer = setTimeout ( ( ) => resolve ( { timeout : true } ) , process . platform === 'win32' ? 5_000 : 1_000 ) ; timer . unref ( ) ; } ) ,
147149 ] ) ;
148150 if ( outcome . timeout ) runner . kill ( 'SIGKILL' ) ;
149151 assert . deepEqual ( outcome , { code : 0 , signal : null } , stderr || 'strict child did not finish' ) ;
0 commit comments