Provide a way to get worker initialization error synchronously
未关闭
还没有人认领这个 Issue。
feature request
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.3k
- 平均合并
- 4 天 2 小时
- 30 天内合并 PR
- 283
描述
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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 worker_threads Worker 的初始化和 error-event 行为开始,使用包含语法错误的 data URL 进行复现。检查 Atomics.wait() 如何与 worker 启动交互,然后定义并测试同步初始化失败在不依赖 timeout 的情况下应呈现什么样子。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- backend
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100