When `ReadableStream` read fails, stack trace does not include the line responsible
Chưa có ai nhận issue này.
- 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
22.2.0
Platform
Microsoft Windows NT 10.0.22635.0 x64
Subsystem
No response
What steps will reproduce the bug?
Save the following code to a file and run it:
import net from 'node:net'
import stream from 'node:stream'
const socket = net.connect(90, 'host.invalid.',)
socket.on("error", e => { console.warn("socket error:", e.message) })
let myStream = stream.Duplex.toWeb(socket)
console.log("next line throws")
await myStream.readable.getReader().read()
console.log("this line will never be reached")
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
From the output, you can see there was an error, but you can't see why that crashed the process. The output should mention the line number of the read() call so that the user can add necessary error handling.
Note that --async-stack-traces does not make the output any more useful.
What do you see instead?
> node index.mjs
next line throws
socket error: getaddrinfo ENOTFOUND host.invalid.
node:internal/modules/run_main:115
triggerUncaughtException(
^
Error: getaddrinfo ENOTFOUND host.invalid.
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'host.invalid.'
}
Additional information
A bad and easy to forget workaround is to wrap each await call.
await reader.read().catch(e => { throw new AggregateError([e]) })
A better workaround might be possible with the (discouraged) async hooks API.
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
Bắt đầu bằng cách chạy bản tái hiện được cung cấp trong index.mjs với Node.js 22.2.0 và kiểm tra ReadableStream reader cũng như việc truyền lỗi liên quan đến stream.Duplex.toWeb(socket). Hoàn thành có nghĩa là lỗi chưa được bắt phải bao gồm vị trí nguồn của lệnh gọi read(), cùng với một regression test bao phủ đường dẫn read bị 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
- 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
- 45/100