Stream finished does not always work with http incoming message
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: v15.12.0
- Platform: Darwin Kernel Version 20.3.0
- Subsystem: http
What steps will reproduce the bug?
The stream.finished never resolves or rejects when applied onto a destroyed incoming message like in example below. It finishes for example when applied on a destroyed file stream. Also it finishes when the line with await new Promise(r => setTimeout(r, 1000)); is commented. This looks really inconsistent.
let http = require("http");
let { finished } = require("stream/promises");
let server = http.createServer(async function(req, res)
{
for await (let chunk of req) break;
await new Promise(r => setTimeout(r, 1000));
console.log("waiting");
await finished(req);
console.log("sending");
res.end();
});
(async function()
{
await new Promise(resolve => server.listen(resolve));
let req = http.request({ port: server.address().port, method: "post" }).end("abc");
try
{
let res = await new Promise((resolve, reject) => req.on("response", resolve).on("error", reject));
await finished(res.resume());
}
catch(e)
{
console.log(e);
}
}());
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
Error: socket hang up
waiting
sending
What do you see instead?
Error: socket hang up
waiting
Additional information
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 http.createServer được cung cấp trên Node v15.12.0 và theo dõi tương tác giữa request đến, hàm finished của stream/promises và await bị trì hoãn. So sánh hành vi của request bị hủy với hành vi của luồng tệp được nêu trong báo cáo. Hoàn tất khi bản tái hiện đạt đến "sending" và tạo ra đầu ra socket hang-up như mong đợ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
- Lĩnh vực
- networking
- 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