nodejs / nodejs/node

Pause on uncaught exceptions stops at wrong position with ES modules

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

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

esm inspector
主要言語
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?

Here's a repo with an easy reproduction:

  1. Open the repo in VS Code (or you can use another tool/any debugger)
  2. In the debug view (play button on the left hand side):
    • Check the [x] Uncaught Exceptions box in the breakpoints view.
    • Select "No Bug" and hit the play button. This runs no-bug/index.js.
  3. The debugger pauses at the location of the throw
  4. Now select "Repro Bug", and hit the play button. This runs bug/index.js: the same code in an ES module.
  5. The debugger pauses inside internal Node.js module code:

Under the hood this is just calling Debugger.setPauseOnExceptions({ state: 'uncaught' }), so it should be reproducable with any tool. In both cases this leads to a Debugger.pause, with the latter in the wrong location.

I'm guessing there's some inspector ✨magic that happens with commonjs that isn't happening for ES modules.

How often does it reproduce? Is there a required condition?

100%

What is the expected behavior?

In both cases, the debugger should pause on the throw

What do you see instead?

In ES modules, it pauses in module_job.js.

Additional information

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

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

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

はじめの一歩

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

調査の方向性

まず、デバッガーの未捕捉例外設定を使って、リンク先の node-38439 リポジトリで問題を再現し、no-bug/index.js と bug/index.js を比較します。module_job.js 周辺の一時停止処理と inspector のエントリーポイントを読みます。完了条件は、ES モジュールが内部モジュールコード内ではなく throw の位置で一時停止することです。

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

評価

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

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

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