From 4f06929e5e38a56f51bed9ec194e1abf7ab836c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 12:05:08 +0000 Subject: [PATCH 1/3] Initial plan From dfc642479ed08ec0eb81fd12c573cd0ce263e4ff Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 12:07:57 +0000 Subject: [PATCH 2/3] Improve error handling in createZip function Co-authored-by: madebydavid <5401249+madebydavid@users.noreply.github.com> --- src/utils/zip.ts | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/utils/zip.ts b/src/utils/zip.ts index f868e80..88b582f 100644 --- a/src/utils/zip.ts +++ b/src/utils/zip.ts @@ -51,6 +51,25 @@ export async function createZip({files, outputPath, onProgress}: CreateZipProps) } return new Promise((resolve, reject) => { + let settled = false + + const handleError = (error: Error) => { + if (settled) return + settled = true + + // Clean up streams + outputStream.destroy() + progressStream.destroy() + + reject(error) + } + + const handleSuccess = () => { + if (settled) return + settled = true + resolve() + } + const outputStream = fs.createWriteStream(outputPath) const progressStream = createProgressStream(estimatedZipSize, (written, total) => { @@ -66,11 +85,15 @@ export async function createZip({files, outputPath, onProgress}: CreateZipProps) }) }, ON_PROGRESS_THROTTLE_MS) + // Add error handlers to all streams in the pipe chain + zipFile.outputStream.on('error', handleError) + progressStream.on('error', handleError) + outputStream.on('error', handleError) + outputStream.on('close', handleSuccess) + zipFile.outputStream .pipe(progressStream) .pipe(outputStream) - .on('close', () => resolve()) - .on('error', reject) zipFile.end() }) From 76277cb0c122872533e05d5387291eb0552b8fb8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 12:09:54 +0000 Subject: [PATCH 3/3] Add zipFile.outputStream cleanup to prevent resource leaks Co-authored-by: madebydavid <5401249+madebydavid@users.noreply.github.com> --- src/utils/zip.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/zip.ts b/src/utils/zip.ts index 88b582f..68a7e59 100644 --- a/src/utils/zip.ts +++ b/src/utils/zip.ts @@ -58,8 +58,9 @@ export async function createZip({files, outputPath, onProgress}: CreateZipProps) settled = true // Clean up streams - outputStream.destroy() + zipFile.outputStream.destroy() progressStream.destroy() + outputStream.destroy() reject(error) }