fix: abort ZIP responses when the streamer fails

This commit is contained in:
Thomas Durieux committed 2026-10-07 10:34:43 +00:00
1 parent 2fb4b8fabd
commit f32b2c6eb7
2 files changed
+77 -1

No files matched your search

+5 -1
View File
@@ -112,7 +112,7 @@ router.get(
upstreamStatus,
upstreamBody: upstreamBody?.slice(0, 500),
url: config.STREAMER_ENTRYPOINT
? join(config.STREAMER_ENTRYPOINT, "api/zip")
? join(config.STREAMER_ENTRYPOINT, "api/download")
: undefined,
err: serializeError(err),
});
@@ -124,6 +124,10 @@ router.get(
}),
res
);
// Once ZIP bytes have been sent, handleError cannot send JSON.
// Terminate the truncated response so the client reports failure
// instead of waiting forever for the ZIP's central directory.
if (res.headersSent && !res.writableEnded) res.destroy();
});
reqStream.pipe(res);
res.on("close", () => {