nodejs / nodejs/node

Provide a way to get worker initialization error synchronously

オープン
#51,679 コメント 12 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

feature request
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

worker_threads Worker の初期化と error-event の動作から始め、構文エラーのある data URL を再現に使用します。Atomics.wait() が worker の起動とどのように相互作用するかを確認し、そのうえで、タイムアウトに依存せずに同期的な初期化失敗がどのようになるべきかを定義してテストします。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
backend
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。