Open
Description
Version
22.4.0 (i also tried earlier versions and the bug is always present)
Platform
Both in Linux and Windows, all OS versions.
Subsystem
worker_threads
What steps will reproduce the bug?
const { Worker } = require("worker_threads");
let worker = new Worker(`function print_three_and_work(){
console.log("a");
console.log("b");
console.log("c");
while(true){}
}
print_three_and_work();`, {eval: true});
or
const { Worker } = require("worker_threads");
let worker = new Worker(`function print_three_and_work(){
console.log("a");
console.log("b");
console.log("c");
while(true){}
}
print_three_and_work();`, {eval: true, stdout: true});
worker.stdout.on("data", function(chunk){
process.stdout.write(chunk);
});
How often does it reproduce? Is there a required condition?
It always happens.
What is the expected behavior? Why is that the expected behavior?
All logged messages should be piped to the main thread's stdout while the worker is running.
What do you see instead?
Only the first message is piped. All other messages are not piped while the worker is running. They get piped all at once once the worker stops running.
(I see "a" instead of seeing "a \n b \n c".)
Additional information
I believe this other issue has a similar problem but it was misunderstood as having something to do with "process.exit", while instead it must be because of something else.