history-v1: handle ERR_STREAM_PREMATURE_CLOSE in streamZip (#36135)

GitOrigin-RevId: 963b65583da58034afe304206f6e0c66e9186b06
This commit is contained in:
Anna Claire Fields
2026-09-17 11:49:33 +00:00
committed by Copybot
parent d9e7900246
commit b8339c5b4a
@@ -320,7 +320,18 @@ async function streamZip(snapshot, blobStore, res) {
res.set('Content-Type', 'application/octet-stream')
res.set('Content-Disposition', 'attachment; filename=project.zip')
const stream = fs.createReadStream(tmpFilename)
await pipeline(stream, res)
try {
await pipeline(stream, res)
} catch (err) {
if (
err?.code === 'ERR_STREAM_PREMATURE_CLOSE' ||
err?.code === 'ERR_STREAM_UNABLE_TO_PIPE'
) {
res.end()
} else {
throw err
}
}
})
}