- Version: v11.0.0-pre
- Platform: OSX
- Subsystem: worker_threads
It appears that workers don't get sent messages if the sending thread uses Atomics.wait to block the thread sending the message.
// main.mjsimportworkerfrom'worker_threads';constchild=newworker.Worker(newURL('./worker.js',import.meta.url).pathname);constshared=newInt32Array(newSharedArrayBuffer(4));child.postMessage({shared});// removing the following line allows {shared} to be passed to the workerAtomics.wait(shared,0,0);// worker.jsconst{parentPort}=require('worker_threads');parentPort.on('message',({shared})=>{// never gets hereconsole.log('worker got message',shared);Atomics.wake(shared,0);});
It appears that workers don't get sent messages if the sending thread uses
Atomics.waitto block the thread sending the message.