Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worker.onmessage is not called #26856

Closed
surma opened this issue Mar 22, 2019 · 6 comments
Closed

worker.onmessage is not called #26856

surma opened this issue Mar 22, 2019 · 6 comments
Labels
feature request Issues that request new features to be added to Node.js. stale worker Issues and PRs related to Worker support.

Comments

@surma
Copy link

surma commented Mar 22, 2019

// 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

@BridgeAR BridgeAR added the worker Issues and PRs related to Worker support. label Mar 27, 2019
@GrosSacASac
Copy link
Contributor

Thanks, we should also consider supporting .addEventListener and .removeEventListener as well.
Web Worker in the browser support it.

@jasnell jasnell added the feature request Issues that request new features to be added to Node.js. label Jun 26, 2020
@jasnell
Copy link
Member

jasnell commented Jun 26, 2020

Refs: #34057

@addaleax
Copy link
Member

To be clear, #34057 does this for MessagePort, not Worker. I’m not sure whether we really want this for the Worker class itself.

@jasnell
Copy link
Member

jasnell commented Jun 26, 2020

Yep, not really seeing much value in having Worker extend EventTarget right now.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2022

There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Mar 8, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Apr 8, 2022

There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.

For more information on how the project manages feature requests, please consult the feature request management document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. stale worker Issues and PRs related to Worker support.
Projects
None yet
Development

No branches or pull requests

5 participants