Skip to content

Atomics.wait prevents postMessage being queued #21417

Closed
@bmeck

Description

@bmeck
  • 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);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions