Skip to content

Commit

Permalink
chore: keep all zone data in Zone.run()
Browse files Browse the repository at this point in the history
  • Loading branch information
dgozman committed Jan 9, 2025
1 parent 9b58e4a commit 53c539a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/playwright-core/src/utils/zones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ZoneManager {

export class Zone {
private readonly _asyncLocalStorage: AsyncLocalStorage<Zone | undefined>;
private readonly _data: Map<ZoneType, unknown>;
private readonly _data: ReadonlyMap<ZoneType, unknown>;

static _createWithData(asyncLocalStorage: AsyncLocalStorage<Zone|undefined>, type: ZoneType, data: unknown) {
const store = new Map(asyncLocalStorage.getStore()?._data);
Expand All @@ -60,10 +60,7 @@ export class Zone {
}

run<R>(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<T>(type: ZoneType): T | undefined {
Expand Down

0 comments on commit 53c539a

Please sign in to comment.