Reopen of: Problems with cooperation between http and pipeline/"for await"
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
v20.5.1
Platform
Darwin Kernel Version 22.6.0
Subsystem
http
What steps will reproduce the bug?
https://github.com/nodejs/node/issues/38262
https://github.com/nodejs/node/issues/38262#issuecomment-991233190
This often stops after the first iteration:
let http = require("http");
let server = http.createServer(async function(req, res)
{
try
{
let len = 0;
for await (let chunk of req)
{
len += chunk.length;
if(len > 2) throw "payload too large";
}
res.end("ok");
}
catch(err)
{
console.log("server log:", err);
res.end(err);
}
});
(async function()
{
await new Promise(resolve => server.listen(8888, resolve));
let agent = new http.Agent({ keepAlive: true });
let data = Buffer.alloc(1000000);
for(let i = 0; ; i++)
{
console.log(i);
let req = http.request({ port: 8888, method: "post", agent }).end(data);
let res = await new Promise((resolve, reject) => req.on("response", resolve).on("error", reject));
let str = "";
for await (let chunk of res) str += chunk;
console.log(str);
}
}());
How often does it reproduce? Is there a required condition?
Often.
What is the expected behavior? Why is that the expected behavior?
It should continue.
What do you see instead?
0
server log: payload too large
payload too large
1
^C
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 với phiên bản Node.js đã báo cáo và so sánh hành vi của nó với issue #38262 cùng bình luận được liên kết. Theo dõi việc xử lý trình lặp bất đồng bộ của request/response HTTP xung quanh for await, việc xử lý request bị từ chối và keep-alive agent. Được xem là hoàn tất khi vòng lặp lặp lại tiếp tục ổn định sau payload quá lớn thay vì dừng lại sau lần lặp đầu tiên.
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, networking
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 52/100