diff --git a/packages/playwright-core/src/utils/zones.ts b/packages/playwright-core/src/utils/zones.ts index 15487d3595fda..035213c50de53 100644 --- a/packages/playwright-core/src/utils/zones.ts +++ b/packages/playwright-core/src/utils/zones.ts @@ -42,7 +42,7 @@ class ZoneManager { export class Zone { private readonly _asyncLocalStorage: AsyncLocalStorage; - private readonly _data: Map; + private readonly _data: ReadonlyMap; static _createWithData(asyncLocalStorage: AsyncLocalStorage, type: ZoneType, data: unknown) { const store = new Map(asyncLocalStorage.getStore()?._data); @@ -60,10 +60,7 @@ export class Zone { } run(func: () => R): R { - // Reset apiZone and expectZone, but restore stepZone. - const entries = [...this._data.entries()].filter(([type]) => (type !== 'apiZone' && type !== 'expectZone')); - const resetZone = new Zone(this._asyncLocalStorage, new Map(entries)); - return this._asyncLocalStorage.run(resetZone, func); + return this._asyncLocalStorage.run(this, func); } get(type: ZoneType): T | undefined {