-
Notifications
You must be signed in to change notification settings - Fork 622
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
feat(node): worker_threads #1151
Conversation
CI errors are related to denoland/deno#9696. |
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.
This looks good @Mesteery, but please some more tests that actually execute some code in workers.
Yes of course, the more complete tests are already added locally. |
e6cb287
to
0612616
Compare
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.
This is almost ready except for...
node/worker_threads.ts
Outdated
@@ -0,0 +1,217 @@ | |||
/// <reference lib="webworker"/> |
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.
The tests fail systematically because of the typing errors involved in this reference, so the solution to make it work is --no-check
. Do you know another way?
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.
@kitsonk could you please advice on this situation?
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.
Does /// <reference lib="deno.worker" />
fix it?
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.
0612616
to
299b473
Compare
Ooops, looks like I borked the merge. |
no worries, it's fixed |
@Mesteery I discussed this offline with @kitsonk. We believe the way forward right now is to use
Would be happy to land it for tomorrow's release if you manage to fix those errors. |
It's an exposed interface too: https://html.spec.whatwg.org/multipage/workers.html#dedicatedworkerglobalscope |
Ooops, silly me, I checked it in Chrome's console without spawning a worker 🤦♂️ |
I've amended the files so they type check now. Side note, I know we went for |
node/events.ts
Outdated
|
||
emitter.once(name, eventListener); | ||
return; | ||
emitter.once("error", errorListener); |
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.
This line is now failing "Can add once event listener to EventTarget via standalone function"
test
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.
Okay, i will fix this.
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 disabled this test for now and opened #1455
It's a shame this one got derailed, the PR seemed to be very close! |
@guybedford this PR is more or less complete, however there's still problem with TS types. I wonder if we should maybe skip typings completely for the time being and just land it. |
6deed69
to
0ba2ab4
Compare
I think I managed to fix type errors. PTAL @bartlomieju @kitsonk |
This is a blocker for |
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.
require
and compat APIs are not available to workers. Can we please add that? EDIT: Needs support in CLI
Sorry but I am not familiar with Deno. What do you mean by that? |
This is something I will work on, currently worker API doesn't respect "compat" mode and doesn't add required globals. |
After a lot back and forth I found the root problem of the implementation of this PR. Currently tests fails with "Module execution is still pending but there are no pending ops..." suggesting that there's a promise that never resolves. I found that this is caused by Alternatively we would have apply a lot of code from |
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.
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.
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.
@Mesteery Thank you for your initial work!
No description provided.