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 + } + } }) }