Stream finished does not always work with http incoming message
Nessuno ha ancora preso questa issue.
- 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
- 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
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 di http.createServer su Node v15.12.0 e tracciando l’interazione tra la richiesta in ingresso, la funzione finished di stream/promises e l’await ritardato. Confronta il comportamento della richiesta distrutta con quello del flusso di file mostrato nel report. Il lavoro è completato quando la riproduzione raggiunge "sending" e produce l’output socket hang-up previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- networking
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100