From b8339c5b4ab6cdd50ad744b5b0e3f00134f268e3 Mon Sep 17 00:00:00 2001 From: Anna Claire Fields <58918237+franklovefrank@users.noreply.github.com> Date: Thu, 6 Aug 2026 14:18:25 +0200 Subject: [PATCH] history-v1: handle ERR_STREAM_PREMATURE_CLOSE in streamZip (#36135) GitOrigin-RevId: 963b65583da58034afe304206f6e0c66e9186b06 --- services/history-v1/api/controllers/projects.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/services/history-v1/api/controllers/projects.js b/services/history-v1/api/controllers/projects.js index 428800a654..c8042ba6f3 100644 --- a/services/history-v1/api/controllers/projects.js +++ b/services/history-v1/api/controllers/projects.js @@ -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 + } + } }) }