Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(tracing): race in stopChunk (#10481)
Dmitry Gozman7d3672899f86
diff --git a/packages/playwright-core/src/server/trace/recorder/tracing.ts b/packages/playwright-core/src/server/trace/recorder/tracing.tsindex 9620bdfe3f..a3fdfd3a2b 100644--- a/packages/playwright-core/src/server/trace/recorder/tracing.ts+++ b/packages/playwright-core/src/server/trace/recorder/tracing.ts@@ -172,6 +172,18 @@ export class Tracing implements InstrumentationListener, SnapshotterDelegate, Hathrow new Error(`Tracing is already stopping`);this._isStopping = true;+ if (!this._state || !this._state.recording) {+ this._isStopping = false;+ if (save)+ throw new Error(`Must start tracing before stopping`);+ return { artifact: null, entries: [] };+ }++ const state = this._state!;+ this._context.instrumentation.removeListener(this);+ if (this._state?.options.screenshots)+ this._stopScreencast();+for (const { sdkObject, metadata, beforeSnapshot, actionSnapshot, afterSnapshot } of this._pendingCalls.values()) {await Promise.all([beforeSnapshot, actionSnapshot, afterSnapshot]);let callMetadata = metadata;@@ -185,17 +197,6 @@ export class Tracing implements InstrumentationListener, SnapshotterDelegate, Haawait this.onAfterCall(sdkObject, callMetadata);}- if (!this._state || !this._state.recording) {- this._isStopping = false;- if (save)- throw new Error(`Must start tracing before stopping`);- return { artifact: null, entries: [] };- }-- const state = this._state!;- this._context.instrumentation.removeListener(this);- if (state.options.screenshots)- this._stopScreencast();if (state.options.snapshots)await this._snapshotter.stop();