nodejs / nodejs/node

Http client sometimes returns EPIPE when server does not read request body

未关闭
#38,467 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

http
主要语言
JavaScript
星标
122k
派生
37.4k
平均合并
4 天 3 小时
30 天内合并 PR
272

描述

  • Version: v15.12.0
  • Platform: Darwin Kernel Version 20.3.0
What steps will reproduce the bug?
let http = require("http");

let server = http.createServer(async function(req, res)
{
	res.end("ok");
});

(async function()
{
	await new Promise(resolve => server.listen(resolve));
	let buf = Buffer.alloc(50000000);
	for(let i = 0; ; i++)
	{
		let req = http.request({ port: server.address().port, method: "post" }).end(buf);
		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(i, "client received:", str);
	}
}());
How often does it reproduce? Is there a required condition?

Sometimes. It can take a few thousands of iterations or more.

What is the expected behavior?

No EPIPE.

What do you see instead?
85784 client received: ok
node:internal/process/promises:245
          triggerUncaughtException(err, true /* fromPromise */);
          ^

Error: write EPIPE
    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}
Additional information

It does not happen on linux (after more than million iterations).

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先在 Darwin 上运行提供的 HTTP 客户端/服务器复现,并将其行为与 Linux 进行比较。该 payload 没有指出源文件或测试,因此请跟踪与 EPIPE 相关的 HTTP 客户端请求体写入路径,并确定一个有针对性的回归测试。当服务器不读取请求体时,该复现不再产生 EPIPE,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, node.js
领域
backend, networking
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。