Skip to content

Commit 8d1c87e

Browse files
committed
test: fix race in parallel/test-vm-debug-context
Fix a race condition in parallel/test-vm-debug-context where the 'exit' event for the child process is emitted before the first and only 'data' event for the child process's stderr stream. I considered deferring the 'exit' event in lib/child_process.js until all stdio streams have been closed but I realized that's not going to work when the child process spins off grandchildren that keep the stdio file descriptors alive. Fixes: #1291 PR-URL: #1294 Reviewed-By: Brendan Ashworth <[email protected]>
1 parent ea37ac0 commit 8d1c87e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/parallel/test-vm-debug-context.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ var proc = spawn(process.execPath, [script]);
5858
var data = [];
5959
proc.stdout.on('data', assert.fail);
6060
proc.stderr.on('data', data.push.bind(data));
61+
proc.stderr.once('end', common.mustCall(function() {
62+
var haystack = Buffer.concat(data).toString('utf8');
63+
assert(/SyntaxError: Unexpected token \*/.test(haystack));
64+
}));
6165
proc.once('exit', common.mustCall(function(exitCode, signalCode) {
6266
assert.equal(exitCode, 1);
6367
assert.equal(signalCode, null);
64-
var haystack = Buffer.concat(data).toString('utf8');
65-
assert(/SyntaxError: Unexpected token \*/.test(haystack));
6668
}));
6769

6870
var proc = spawn(process.execPath, [script, 'handle-fatal-exception']);

0 commit comments

Comments
 (0)