-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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_threads parentPort extends EventTarget in Node 14 but extends EventEmitter in Node 12 #35835
Comments
So … I’m conflicted – on the one hand, this is working as expected. That being said, the fact that (Either way, I’ll have to go update my slides for nodeconf.remote next week … 😄) |
Also: Yes, this is definitely missing documentation updates. I’ll get onto that. @snowinferno Is this causing any real-world trouble? I’m surprised that |
It's not causing real world trouble yet. The company I work for is mainly on Node 10 and 12 while we prepare for and test Node 14. I happened to be using node 14 when I ran a test with worker_thread code to perform some tasks. In the event an error happens during processing, we're using
|
The module I'm working on is in a state where it is being picked up by application builds but the method of triggering it is not yet user-friendly. If the decision is to leave the worker_thread implementation as-is, we will have to prioritize changing how errors get bubbled up before we make Node 14 available for production applications. |
I think it's fine to shim this (
Probably
Good luck with your talk! |
Ok, but just so we’re on the same page – |
BTW Would it help (you) at all if I worked this? (made a PR that adds (I am happy to do it if it's helpful) |
@benjamingr I mean, I’d get to it at some point, but feel free to pick this up if you like :) |
Hmm, one possible difference is support for multiple args - I'll do what I can and I'll make a PR to dicusss the "product" of how "emit" can look. |
@addaleax how would you feel about a It would be the default for Also - we currently use |
The name sounds good to me :)
That’s fine, although we should make sure that the
I think |
Opened a PR in #35851 with a bunch of questions |
@addaleax Ahh, I see. So we are actually creating a side-effect that just happened to bubble up through |
What steps will reproduce the bug?
Run this script under node v14.15.0
How often does it reproduce? Is there a required condition?
Every time the script is run.
Required condition: Node v14.15.0
What is the expected behavior?
The error should reflect
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('This is my error message.')
with a stack trace.What do you see instead?
The error reflects
TypeError [Error]: parentPort.emit is not a function
with a stack trace.parentPort
seemingly does not extendEventEmitter
as documentation indicates and behavior under node v12.19.0 shows.Additional information
This appears to be related to commit 0aa3809b6be on the v14.x branch
This would be a breaking change in a stable API since this same script behaves as expected under Node v12.19.0.
Inspecting
parentPort
I find that contrary to expectation and documentation, it extendsEventTarget
instead ofEventEmitter
.The text was updated successfully, but these errors were encountered: