Provide a way to get worker initialization error synchronously
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
What is the problem this feature will solve?
I'm using a worker to run asynchronous tasks and block the main thread with Atomics.wait().
If the worker has something like syntax errors, it seems that we can only get it by add a listener to error event, the program just hangs since worker can not wake the main thread.
new (require('worker_threads').Worker)(new URL('data:text/javascript,throw new Error'));
What is the feature you are proposing to solve the problem?
Provide a way to get the worker initialization error synchronously.
What alternatives have you considered?
I tried to pass a timeout to Atomics.wait(), but It's just a random magic number because I don't know how long the worker script takes to init.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the worker_threads Worker initialization and error-event behavior, using the data URL with a syntax error as the reproduction. Check how Atomics.wait() interacts with worker startup, then define and test what synchronous initialization failure should look like without relying on a timeout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100