-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
fix(ext/node): MessagePort works #22999
Conversation
@satyarohith do you need any help with landing this PR? Would be great if we could land it before v1.42 this week. |
Yes. I'm trying to figure out how close event would be emitted when either of the ports get closed. |
I think you can override the |
Additionally you can emit the event in To do that you probably want to add a private API that allows to call a callback in either of these situations - you'd install the callback if the |
This patch allows the example code to work but theoritically close() should emit "close" event on both the ports of a channel (see https://nodejs.org/api/worker_threads.html#portclose) but that's not being done here. We need to address that.
c1074c3
to
653d268
Compare
This PR is working but the order of events fired is not similar to node:
And according to https://nodejs.org/api/worker_threads.html#portclose, we need to emit "close" event on both the ports of a channel when either of the port is closed which is not happening right now. |
itest_flaky!(node_worker_message_port { | ||
args: "run --quiet --allow-read workers/node_worker_message_port.mjs", | ||
output: "workers/node_worker_message_port.mjs.out", | ||
exit_code: 0, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it passes sometimes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I marked it as flaky because the order is not predictable. But it doesn't match the output of Node even in a single instance.
@@ -16,7 +16,7 @@ Deno.test("[node/worker_threads] BroadcastChannel is exported", () => { | |||
}); | |||
|
|||
Deno.test("[node/worker_threads] MessageChannel are MessagePort are exported", () => { | |||
assertEquals<unknown>(workerThreads.MessageChannel, MessageChannel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the MessageChannel exported from worker_threads is now NodeMessageChannel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, let's address the ordering problem in a separate PR.
Closes #22951 Closes #23001 Co-authored-by: Divy Srivastava <[email protected]>
Work in progress.
TODO:
Closes #22951
Closes #23001