fix(cli): close asset streams when clients disconnect (#5321)

* fix(cli): close asset streams when clients disconnect

* chore: prepare conflict resolution against current main

* fix(cli): retain asset disconnect cleanup with current main
This commit is contained in:
Abdullah M. Nazif
2026-10-24 04:11:02 +00:00
committed by GitHub
parent 58752b5cf3
commit 410030a733
2 changed files with 69 additions and 2 deletions
@@ -171,6 +171,7 @@ function serveFileWithRange(
// just `[start, end]` and closes its own fd on end/error. writeHead is
// deferred to `open` so a failed open can still answer 500.
const stream = createReadStream(filePath, { start, end });
res.once("close", () => stream.destroy());
stream.on("open", () => {
res.writeHead(status, headers);
stream.pipe(res);