Closed
Description
Forked issue from #22938 (comment).
This test case:
const assert = require('assert');
const child_process = require('child_process');
const { promisify } = require('util');
const execFile = promisify(child_process.execFile);
const code =
'console.log(42);process.exit(1)';
{
execFile(process.execPath, ['-e', code])
.catch((err) => {
console.log(`child stderr: >>>\n${err.stderr}<<<`);
assert.strictEqual(err.code, 1);
assert.strictEqual(err.stdout, '42\n');
});
}
Intermittently crashes in the child process on windows when a small IO delay is introduced in the platform worker thread startup:
static void PlatformWorkerThread(void* data) {
fprintf(stderr, ""); // write an empty string to stderr, just to introduce a delay.
TRACE_EVENT_METADATA1("__metadata", "thread_name", "name",
"PlatformWorkerThread");
TaskQueue<Task>* pending_worker_tasks = static_cast<TaskQueue<Task>*>(data);
while (std::unique_ptr<Task> task = pending_worker_tasks->BlockingPop()) {
task->Run();
pending_worker_tasks->NotifyOfCompletion();
}
}
Crash:
C:\workspace\ofrobots\test\common\index.js:662
const crashOnUnhandledRejection = (err) => { throw err; };
^
AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
�[32m+ actual�[39m �[31m- expected�[39m
�[32m+�[39m 3221225477
�[31m-�[39m 1
at execFile.catch.common.mustCall (C:\workspace\ofrobots\test\parallel\test-child-process-promisified.js:47:14)
at C:\workspace\ofrobots\test\common\index.js:349:15
at process._tickCallback (internal/process/next_tick.js:68:7)
The platform worker thread is trying to do IO while the main thread is already shutting things down in exit
.
/cc @nodejs/platform-windows