From 0f2de59b7ca62f47395256e885e65717738430f1 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Wed, 1 Nov 2023 20:17:10 -0700 Subject: [PATCH] chore: remove graceful browser.close cleanup (#27916) --- packages/playwright-core/src/server/browserContext.ts | 10 ++-------- packages/playwright-core/src/server/fetch.ts | 2 +- .../src/server/trace/recorder/tracing.ts | 6 +++++- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/playwright-core/src/server/browserContext.ts b/packages/playwright-core/src/server/browserContext.ts index 3b7b41497b..0bc14f45e1 100644 --- a/packages/playwright-core/src/server/browserContext.ts +++ b/packages/playwright-core/src/server/browserContext.ts @@ -240,13 +240,7 @@ export abstract class BrowserContext extends SdkObject { // at the same time. return; } - const gotClosedGracefully = this._closedStatus === 'closing'; - this._closedStatus = 'closed'; - if (!gotClosedGracefully) { - this._deleteAllDownloads(); - this._downloads.clear(); - } - this.tracing.dispose().catch(() => {}); + this.tracing.abort(); if (this._isPersistentContext) this.onClosePersistent(); this._closePromiseFulfill!(new Error('Context closed')); @@ -422,7 +416,7 @@ export abstract class BrowserContext extends SdkObject { for (const harRecorder of this._harRecorders.values()) await harRecorder.flush(); - await this.tracing.dispose(); + await this.tracing.flush(); // Cleanup. const promises: Promise[] = []; diff --git a/packages/playwright-core/src/server/fetch.ts b/packages/playwright-core/src/server/fetch.ts index b7af65fe51..425d514650 100644 --- a/packages/playwright-core/src/server/fetch.ts +++ b/packages/playwright-core/src/server/fetch.ts @@ -551,7 +551,7 @@ export class GlobalAPIRequestContext extends APIRequestContext { } override async dispose() { - await this._tracing.dispose(); + await this._tracing.flush(); await this._tracing.deleteTmpTracesDir(); this._disposeImpl(); } diff --git a/packages/playwright-core/src/server/trace/recorder/tracing.ts b/packages/playwright-core/src/server/trace/recorder/tracing.ts index 64ba58811c..f5e84f442f 100644 --- a/packages/playwright-core/src/server/trace/recorder/tracing.ts +++ b/packages/playwright-core/src/server/trace/recorder/tracing.ts @@ -249,9 +249,13 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps return this._tracesTmpDir; } - async dispose() { + abort() { this._snapshotter?.dispose(); this._harTracer.stop(); + } + + async flush() { + this.abort(); await this._fs.syncAndGetError(); }