Skip to content

Commit 4fe5c4e

Browse files
Trottruyadorno
authored andcommitted
test: fix flaky test-repl-sigint-nested-eval
There is a race condition where process.kill can be sent before the target is ready to receive the signal. Fixes: #41123 PR-URL: #45354 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 7c79ba7 commit 4fe5c4e

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

‎test/parallel/parallel.status‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ prefix parallel
55
# sample-test : PASS,FLAKY
66

77
[true] # This section applies to all platforms
8-
# https://github.com/nodejs/node/issues/41123
9-
test-repl-sigint-nested-eval: PASS, FLAKY
108
# https://github.com/nodejs/node/issues/43084
119
test-worker-http2-stream-terminate: PASS, FLAKY
1210

‎test/parallel/test-repl-sigint-nested-eval.js‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ if (!common.isMainThread)
1010
constassert=require('assert');
1111
constspawn=require('child_process').spawn;
1212

13-
process.env.REPL_TEST_PPID=process.pid;
1413
constchild=spawn(process.execPath,['-i'],{
15-
stdio: [null,null,2]
14+
stdio: [null,null,2,'ipc']
1615
});
1716

1817
letstdout='';
@@ -22,17 +21,19 @@ child.stdout.on('data', function(c){
2221
});
2322

2423
child.stdout.once('data',common.mustCall(()=>{
25-
process.on('SIGUSR2',common.mustCall(()=>{
24+
child.on('message',common.mustCall((msg)=>{
25+
assert.strictEqual(msg,'repl is busy');
2626
process.kill(child.pid,'SIGINT');
2727
child.stdout.once('data',common.mustCall(()=>{
2828
// Make sure REPL still works.
2929
child.stdin.end('"foobar"\n');
3030
}));
3131
}));
3232

33-
child.stdin.write('process.kill(+process.env.REPL_TEST_PPID, "SIGUSR2");'+
34-
'vm.runInThisContext("while(true){}", '+
35-
'{breakOnSigint: true });\n');
33+
child.stdin.write(
34+
'vm.runInThisContext("process.send(\'repl is busy\'); while(true){}", '+
35+
'{breakOnSigint: true });\n'
36+
);
3637
}));
3738

3839
child.on('close',function(code){

0 commit comments

Comments
(0)