nodejs / nodejs/node

Indirectly static import cjs with error will cause an uncaughtException

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

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

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

説明

Version

v20.10.0

Platform

No response

Subsystem

No response

What steps will reproduce the bug?
// ./main.mjs
process.on('uncaughtException', ()=>console.log('uncaught'));
try {
    await import(`data:text/javascript,
        import "data:text/javascript,console.log('before')";
        import "${import.meta.url}.cjs";
    `);
}
catch { console.log('caught'); }
// ./main.mjs.cjs
throw Error('abc');
How often does it reproduce? Is there a required condition?

every time

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

same with dynamic await import('./main.mjs.cjs') directly or indirectly.

also intuitive.

What do you see instead?
before
uncaught

and the wrapper dynamic import promise will be forever pending

Additional information

No response

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

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

はじめの一歩

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

調査の方向性

まず、隣接する main.mjs.cjs ファイルとともに main.mjs の再現コードを実行し、動的 import が間接的に import された CommonJS モジュールからのエラーをどのように処理するかを確認します。例が before と caught を出力し、uncaught を出力せず、wrapper の import promise が settle すれば修正完了です。

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

評価

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

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

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