Skip to content

Commit 7d263ff

Browse files
Trottrvagg
authored andcommitted
test: fix unreliable async-hooks/test-signalwrap
Use an interval to keep the event loop open so the test does not exit before receiving all signals fom asynchronous `exec()` calls. PR-URL: #17827Fixes: #14070 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
1 parent 7c6e391 commit 7d263ff

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎test/async-hooks/test-signalwrap.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22
constcommon=require('../common');
33

4-
if(common.isWindows)returncommon.skip('no signals in Windows');
4+
if(common.isWindows)
5+
common.skip('no signals in Windows');
56

67
constassert=require('assert');
78
constinitHooks=require('./init-hooks');
@@ -11,6 +12,10 @@ const exec = require('child_process').exec;
1112
consthooks=initHooks();
1213

1314
hooks.enable();
15+
16+
// Keep the event loop open so process doesn't exit before receiving signals.
17+
constinterval=setInterval(()=>{},9999);
18+
1419
process.on('SIGUSR2',common.mustCall(onsigusr2,2));
1520

1621
constas=hooks.activitiesOfTypes('SIGNALWRAP');
@@ -66,6 +71,7 @@ function onsigusr2() {
6671
}
6772

6873
functiononsigusr2Again(){
74+
clearInterval(interval);
6975
setImmediate(()=>{
7076
checkInvocations(
7177
signal1,{init: 1,before: 2,after: 2,destroy: 1},

0 commit comments

Comments
 (0)