Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(tracing): add missing error handlers in zip repack path (#40760)

Sebastien Tardifb08db6d791d2
diff --git a/packages/playwright-core/src/server/localUtils.ts b/packages/playwright-core/src/server/localUtils.ts
index e52eb66cf0..b6c44cc7b5 100644
--- a/packages/playwright-core/src/server/localUtils.ts
+++ b/packages/playwright-core/src/server/localUtils.ts
@@ -101,7 +101,26 @@ export async function zip(progress: Progress, stackSessions: Map<string, StackSe
return;
}
assert(inZipFile);
+ inZipFile.on('error', error => promise.reject(error));
let pendingEntries = inZipFile.entryCount;
+
+ const finalizeRepack = () => {
+ zipFile.end(undefined, () => {
+ zipFile.outputStream.pipe(fs.createWriteStream(params.zipFile))
+ .on('close', () => {
+ fs.promises.unlink(tempFile).then(() => {
+ promise.resolve();
+ }).catch(error => promise.reject(error));
+ })
+ .on('error', error => promise.reject(error));
+ });
+ };
+
+ if (pendingEntries === 0) {
+ finalizeRepack();
+ return;
+ }
+
inZipFile.on('entry', entry => {
inZipFile.openReadStream(entry, (err, readStream) => {
if (err) {
@@ -109,15 +128,8 @@ export async function zip(progress: Progress, stackSessions: Map<string, StackSe
return;
}
zipFile.addReadStream(readStream!, entry.fileName);
- if (--pendingEntries === 0) {
- zipFile.end(undefined, () => {
- zipFile.outputStream.pipe(fs.createWriteStream(params.zipFile)).on('close', () => {
- fs.promises.unlink(tempFile).then(() => {
- promise.resolve();
- }).catch(error => promise.reject(error));
- });
- });
- }
+ if (--pendingEntries === 0)
+ finalizeRepack();
});
});
});