nodejs / nodejs/node

V8 Inspector is not available in --require in `node --test`

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

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

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

説明

Version

v20.3.0

Platform

Darwin MacBook-Pro-2.local 22.5.0 Darwin Kernel Version 22.5.0: Mon Apr 24 20:51:50 PDT 2023; root:xnu-8796.121.2~5/RELEASE_X86_64 x86_64

Subsystem

test_runner

What steps will reproduce the bug?
  1. Have a file start-inspect.js containing:
const inspector = require("node:inspector");
inspector.open();
  1. Have some other file.test.js, which can be empty.
  2. Run NODE_OPTIONS="--require ./start-inspect.js" node --test ./hello.test.js
How often does it reproduce? Is there a required condition?

100%

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

The inspector should open as usual, as if --test was not given in the CLI

What do you see instead?
$ NODE_OPTIONS="--require ./start-inspect.js" node --test ./hello.test.js

node:inspector:181
  open(port, host);
  ^
This Environment was initialized without a V8::Inspector
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js v20.3.0
Additional information

This does not happen if --test is omitted from the command. This causes issues with the VS/Code debugger which uses this mechanism to initiate debugging. I think Jetbrains does the same thing, so Webstorm and friends probably have the same issue, though I have not tested it.

Also, if I try to open the inspector in the test file itself, it works fine, so it seems like there might be some initialization ordering that's different for --test.

Originally reported on https://github.com/microsoft/vscode-js-debug/issues/1727

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

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

はじめの一歩

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

調査の方向性

まず、start-inspect.js、file.test.js、NODE_OPTIONS、node --test を使って失敗を再現します。--require の実行時における node:inspector 周辺の初期化順序を追跡し、テストファイル内で inspector を開く場合と比較します。コマンドのカバレッジを追加し、--test で inspector が正常に開けば issue は完了とみなします。

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

評価

技術スタック
javascript, nodejs
領域
devtools, testing-qa
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
55/100

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

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