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 <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
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

-2
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

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ if (!common.isMainThread)
1010
const assert = require('assert');
1111
const spawn = require('child_process').spawn;
1212

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

1817
let stdout = '';
@@ -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)