diff --git a/src/common/Page.ts b/src/common/Page.ts index 17f3b634..38e9f900 100644 --- a/src/common/Page.ts +++ b/src/common/Page.ts @@ -507,8 +507,8 @@ export class Page extends EventEmitter { client.on('Target.detachedFromTarget', (event) => { const worker = this._workers.get(event.sessionId); if (!worker) return; - this.emit(PageEmittedEvents.WorkerDestroyed, worker); this._workers.delete(event.sessionId); + this.emit(PageEmittedEvents.WorkerDestroyed, worker); }); this._frameManager.on(FrameManagerEmittedEvents.FrameAttached, (event) =>