nodejs / nodejs/node

Synchronous exceptions in ES modules are always 'caught'

オープン
#50,430 コメント 9 件 リアクション 11 件 担当者 0 名 GitHub で見る

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

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

説明

Version

20.3.1

Platform

Darwin mbp.peet.io 22.6.0 Darwin Kernel Version 22.6.0: Fri Sep 15 13:39:52 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_X86_64 x86_64

Subsystem

inspector

What steps will reproduce the bug?
  1. Start a program containing throw new Error('foo'); in an ES module
  2. Attach a debugger, like devtools or VS Code's debugger, and enable "pause on uncaught exceptions"
  3. Run the program
How often does it reproduce? Is there a required condition?

100%

What is the expected behavior? Why is that the expected behavior?

The runtime should pause on the throw line

What do you see instead?

The runtime does not pause and the program exits

Additional information

First reported in https://github.com/microsoft/vscode-js-debug/issues/1861

Guessing this is because module evaluation is in a try/catch. Wonder if there's any machinery that can be used to mark containing exceptions as uncaught

https://github.com/nodejs/node/blob/0a0b8dfd0d3684d6602599e1f0d9d935b3758700/lib/internal/modules/esm/module_job.js#L217-L219

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

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

はじめの一歩

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

調査の方向性

lib/internal/modules/esm/module_job.js の217〜219行付近から始め、デバッガーをアタッチした状態で同期的な throw を含む ES モジュールを使って問題を再現します。モジュール評価中に inspector が例外をどのように処理するかを追跡します。pause on uncaught exceptions が有効なときに、throw の箇所でデバッガーが一時停止すれば完了です。

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

評価

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

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

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