From 4af389d3716aac84f3b745149dac7dcc519ac593 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 6 Nov 2022 22:41:28 -0800 Subject: [PATCH] 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. Or at least that's what I think is going on. Regardless, objectively, using setTimeout() to slightly delay the invocation causes the test to not fail anymore using: tools/test.py --repeat=1000 test/parallel/test-repl-sigint-nested-eval Fixes: https://github.com/nodejs/node/issues/41123 --- test/parallel/parallel.status | 2 -- test/parallel/test-repl-sigint-nested-eval.js | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index b749eb8497743f..ac0ac19f14401c 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -5,8 +5,6 @@ prefix parallel # sample-test : PASS,FLAKY [true] # This section applies to all platforms -# https://github.com/nodejs/node/issues/41123 -test-repl-sigint-nested-eval: PASS, FLAKY # https://github.com/nodejs/node/issues/43084 test-worker-http2-stream-terminate: PASS, FLAKY diff --git a/test/parallel/test-repl-sigint-nested-eval.js b/test/parallel/test-repl-sigint-nested-eval.js index 28e4d44b235cde..acf21a0abbc524 100644 --- a/test/parallel/test-repl-sigint-nested-eval.js +++ b/test/parallel/test-repl-sigint-nested-eval.js @@ -23,7 +23,7 @@ child.stdout.on('data', function(c) { child.stdout.once('data', common.mustCall(() => { process.on('SIGUSR2', common.mustCall(() => { - process.kill(child.pid, 'SIGINT'); + setTimeout(() => { process.kill(child.pid, 'SIGINT'); }, 10); child.stdout.once('data', common.mustCall(() => { // Make sure REPL still works. child.stdin.end('"foobar"\n');