Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(storage): handle archive errors in the data-export stream (#248)

Yudhi Armyndharisa7c181b35f0f
diff --git a/src/common/storage/storage.service.ts b/src/common/storage/storage.service.ts
index 7569e028c..f0b6622be 100644
--- a/src/common/storage/storage.service.ts
+++ b/src/common/storage/storage.service.ts
@@ -162,6 +162,13 @@ export class StorageService {
gzipOptions: { level: 6 },
});
+ // Surface archive-level failures (gzip/finalize) on the returned stream instead of
+ // letting them become an unhandled rejection or a silently truncated download.
+ archive.on('error', (err: Error) => {
+ this.logger.error('Export archive failed', String(err));
+ output.destroy(err);
+ });
+
archive.pipe(output);
// Add files to archive
@@ -174,7 +181,9 @@ export class StorageService {
}
}
- void archive.finalize();
+ // finalize() rejections also emit via the 'error' handler above; catch the promise so it
+ // never surfaces as an unhandled rejection.
+ archive.finalize().catch(() => undefined);
return output;
}