nodejs / nodejs/node

worker_threads that use es modules incorrectly pause when loaded

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

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

esm inspector worker
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

  • Version: 16.0.0
  • Platform: Win 10 x64
  • Subsystem: inspector
What steps will reproduce the bug?

It's easiest to run under a debugger that supports worker threads, like VS Code's Node.js debugger. I've created an example repo here:

  1. Open the folder in VS Code
  2. In the debug view (play button on the left hand side), select "No Bug" and hit the play button. This runs no-bug/index.js.
  3. A worker thread spawns, logs its message, and exits
  4. Now select "Bug", and hit the play button. This runs bug/index.js: the same code in an ES module.
  5. The debugger pauses on the first line in the worker
How often does it reproduce? Is there a required condition?

100%

What is the expected behavior?

The debugger doesn't pause with ES modules

What do you see instead?

The debugger pauses

Additional information

It looks like Node.js is incorrectly reporting that the program is started with inspectBrk:

VS Code (and Webstorm I think, though I haven't tried to repro there) use a bootloader to inject ourselves into the process via NODE_OPTIONS. We don't actually invoke with --inspect-brk, we manually call inspector.waitForDebugger(). I'm guessing this triggers inspectBrk to be true, but I haven't debugged into it that far.

This was originally reported in https://github.com/microsoft/vscode/issues/122170

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

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

はじめの一歩

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

調査の方向性

VS Code の Node.js デバッガーで bug/index.js と no-bug/index.js を使って問題を再現します。まず、inspector.waitForDebugger() の呼び出しと、関連付けられた VS Code bootloader の周辺における ES-module と non-module の worker の動作を比較します。ES-module のケースでデバッガーが worker の最初の行で停止しなくなれば完了です。

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

評価

技術スタック
javascript, nodejs
領域
devtools
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

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

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