nodejs / nodejs/node

Pause on uncaught exceptions stops at wrong position with ES modules

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

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

esm inspector
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: 16.0.0
  • Platform: Win 10 x64
  • Subsystem: inspector
What steps will reproduce the bug?

Here's a repo with an easy reproduction:

  1. Open the repo in VS Code (or you can use another tool/any debugger)
  2. In the debug view (play button on the left hand side):
    • Check the [x] Uncaught Exceptions box in the breakpoints view.
    • Select "No Bug" and hit the play button. This runs no-bug/index.js.
  3. The debugger pauses at the location of the throw
  4. Now select "Repro Bug", and hit the play button. This runs bug/index.js: the same code in an ES module.
  5. The debugger pauses inside internal Node.js module code:

Under the hood this is just calling Debugger.setPauseOnExceptions({ state: 'uncaught' }), so it should be reproducable with any tool. In both cases this leads to a Debugger.pause, with the latter in the wrong location.

I'm guessing there's some inspector ✨magic that happens with commonjs that isn't happening for ES modules.

How often does it reproduce? Is there a required condition?

100%

What is the expected behavior?

In both cases, the debugger should pause on the throw

What do you see instead?

In ES modules, it pauses in module_job.js.

Additional information

This was originally reported in https://github.com/microsoft/vscode/issues/122246

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 vấn đề từ repository node-38439 được liên kết với cài đặt ngoại lệ chưa được bắt của debugger, đồng thời so sánh no-bug/index.js với bug/index.js. Đọc phần xử lý tạm dừng xung quanh module_job.js và các entry point của inspector; hoàn tất khi các module ES tạm dừng tại vị trí throw thay vì bên trong mã module nội bộ.

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
52/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.