-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Closed
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.staleworkerIssues and PRs related to Worker support.Issues and PRs related to Worker support.
Description
// main.mjs
import {Worker} from 'worker_threads';
const worker = new Worker("./worker.mjs");
worker.onmessage = ev => console.log("onmessage", ev);
worker.on("message", ev => console.log("EventEmitter", ev));
worker.postMessage("from main to worker")
// worker.mjs
import {parentPort} from 'worker_threads';
parentPort.onmessage = ev => console.log(ev);
parentPort.postMessage("from worker to main");
If you run the main.mjs
file above, you’ll see only the EventEmitter handler is called, but not the one registered via onmessage
.
I think for consistence (as well as the fake MessageEvent handling introduced in #26082), it is desirable to add support for onmessage
on Worker
.
cc @addaleax
UziTech and tpamula
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.staleworkerIssues and PRs related to Worker support.Issues and PRs related to Worker support.