Closed
Description
- 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.mjs
import worker from 'worker_threads';
const child = new worker.Worker(new URL('./worker.js', import.meta.url).pathname);
const shared = new Int32Array(new SharedArrayBuffer(4));
child.postMessage({shared});
// removing the following line allows {shared} to be passed to the worker
Atomics.wait(shared, 0, 0);
// worker.js
const {parentPort} = require('worker_threads');
parentPort.on('message', ({shared}) => {
// never gets here
console.log('worker got message', shared);
Atomics.wake(shared, 0);
});