nodejs / nodejs/node

skipFiles does not suppress "uncaught" exceptions in web streams

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

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

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

Mô tả

Version

22.4.1

Platform
Microsoft Windows NT 10.0.22635.0 x64
Subsystem

No response

What steps will reproduce the bug?

Run this code in the VSCode debugger with "skipFiles":["<node_internals>/**"] in the launch configuration.

import net from 'node:net';
import stream from 'node:stream';
const socket = net.connect('http://host.invalid.');
socket.on('error', (e) => {
   console.error('Caught the error', e.message);
});
let myStream = stream.Duplex.toWeb(socket);

setTimeout(() => {
   console.log('done');
}, 1000);
How often does it reproduce? Is there a required condition?

No response

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

It is expected that the debugger won't trip. This promise rejection is entirely created and handled within node's internals and should be suppressed by the VSCode's skipFiles filter.

What do you see instead?

The debugger breaks when the promise is rejected.

The trace (given by console.trace) when it is rejected looks like:

Trace
    at eval (eval-7c2224bb.repl:1:9)
    at Object.reject (<anonymous>)
    at writableStreamRejectCloseAndClosedPromiseIfNeeded (node:internal/webstreams/writablestream:771:28)
    at writableStreamFinishErroring (node:internal/webstreams/writablestream:903:5)
    at writableStreamStartErroring (node:internal/webstreams/writablestream:755:5)
    at writableStreamDefaultControllerError (node:internal/webstreams/writablestream:1202:3)
    at WritableStreamDefaultController.error (node:internal/webstreams/writablestream:502:5)
    at Socket.<anonymous> (node:internal/webstreams/adapters:195:18)
    at Socket.<anonymous> (node:internal/util:538:20)
    at Socket.onclose (node:internal/streams/end-of-stream:152:25)

The stack on the error object is:

'AbortError: The operation was aborted
    at handleKnownInternalErrors (node:internal/webstreams/adapters:111:14)
    at Socket.<anonymous> (node:internal/webstreams/adapters:179:13)
    at Socket.<anonymous> (node:internal/util:538:20)
    at Socket.onclose (node:internal/streams/end-of-stream:152:25)
    at Socket.emit (node:events:532:35)
    at Pipe.<anonymous> (node:net:339:12)
    at Pipe.callbackTrampoline (node:internal/async_hooks:130:17)'

Screenshot 2024-07-09 133433

Additional information

No response

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

Tái hiện ví dụ trong trình gỡ lỗi VSCode với skipFiles được bật, sau đó theo dõi rejection qua node:internal/webstreams/writablestream và node:internal/webstreams/adapters. So sánh cách trình gỡ lỗi xử lý rejection được tạo nội bộ này với các stack frame được hiển thị trong issue; được xem là hoàn tất khi rejection nội bộ không còn làm gián đoạn quá trình thực thi, trong khi các lỗi liên quan trong mã người dùng vẫn có thể gỡ lỗi.

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, node.js
Lĩnh vực
backend, 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
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.