nodejs / nodejs/node

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

Aperta
#38,467 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

http
Lingua principale
JavaScript
Stelle
122k
Fork
37.3k
Merge medio
4g 2h
PR unite (30g)
283

Descrizione

  • 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).

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia eseguendo su Darwin la riproduzione fornita del client/server HTTP e confrontane il comportamento con Linux. Il payload non indica alcun file sorgente né alcun test, quindi traccia il percorso di scrittura del corpo della richiesta del client HTTP associato a EPIPE e individua un test di regressione mirato. Il lavoro è completato quando la riproduzione non produce più EPIPE mentre il server non legge il corpo della richiesta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, node.js
Ambito
backend, networking
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.