nodejs / nodejs/node

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

Đang mở
#48,467 8 bình luận 16 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

inspector test_runner
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.3k
Merge trung bình
4 ngày 2 giờ
Pull request đã merge (30 ngày)
283

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện lỗi với start-inspect.js, file.test.js, NODE_OPTIONS và node --test. Truy vết thứ tự khởi tạo xung quanh node:inspector khi --require chạy, so sánh với việc mở inspector trong tệp kiểm thử. Thêm coverage cho lệnh này và coi issue là hoàn tất khi inspector mở thành công dưới --test.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, nodejs
Lĩnh vực
devtools, testing-qa
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.