Reopen of: Problems with cooperation between http and pipeline/"for await"
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.3k
- Merge medio
- 4g 2h
- PR unite (30g)
- 283
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo la riproduzione fornita con la versione di Node.js indicata e confronta il suo comportamento con l’issue #38262 e il commento collegato. Traccia la gestione degli iteratori asincroni di richiesta/risposta HTTP attorno a for await, l’elaborazione delle richieste rifiutate e il keep-alive agent. Il lavoro è completato quando il ciclo ripetuto continua in modo affidabile dopo il payload sovradimensionato, invece di interrompersi dopo la prima iterazione.
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à
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 52/100