worker_threads that use es modules incorrectly pause when loaded
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.4k
- Merge trung bình
- 4 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 272
Mô tả
- Version: 16.0.0
- Platform: Win 10 x64
- Subsystem: inspector
What steps will reproduce the bug?
It's easiest to run under a debugger that supports worker threads, like VS Code's Node.js debugger. I've created an example repo here:
- Open the folder in VS Code
- In the debug view (play button on the left hand side), select "No Bug" and hit the play button. This runs
no-bug/index.js. - A worker thread spawns, logs its message, and exits
- Now select "Bug", and hit the play button. This runs
bug/index.js: the same code in an ES module. - The debugger pauses on the first line in the worker
How often does it reproduce? Is there a required condition?
100%
What is the expected behavior?
The debugger doesn't pause with ES modules
What do you see instead?
The debugger pauses
Additional information
It looks like Node.js is incorrectly reporting that the program is started with inspectBrk:

VS Code (and Webstorm I think, though I haven't tried to repro there) use a bootloader to inject ourselves into the process via NODE_OPTIONS. We don't actually invoke with --inspect-brk, we manually call inspector.waitForDebugger(). I'm guessing this triggers inspectBrk to be true, but I haven't debugged into it that far.
This was originally reported in https://github.com/microsoft/vscode/issues/122170
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện vấn đề với bug/index.js và no-bug/index.js bằng trình gỡ lỗi Node.js của VS Code. Bắt đầu bằng cách so sánh hành vi của worker ES-module và non-module xung quanh lệnh gọi inspector.waitForDebugger() và VS Code bootloader được liên kết. Hoàn tất khi trình gỡ lỗi không còn dừng ở dòng đầu tiên của worker trong trường hợp ES-module.
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
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 48/100