Skip to content

Commit c63b706

Browse files
authored
fix(events): avoid firing events after close/detach (#2919)
1 parent fc68614 commit c63b706

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/frames.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ export class FrameManager {
7171
this._mainFrame = undefined as any as Frame;
7272
}
7373

74+
dispose() {
75+
for (const frame of this._frames.values())
76+
frame._stopNetworkIdleTimer();
77+
}
78+
7479
mainFrame(): Frame {
7580
return this._mainFrame;
7681
}
@@ -926,6 +931,7 @@ export class Frame {
926931
}
927932

928933
_onDetached() {
934+
this._stopNetworkIdleTimer();
929935
this._detached = true;
930936
this._detachedCallback();
931937
for (const data of this._contextData.values()) {

src/page.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,21 @@ export class Page extends EventEmitter {
145145
}
146146

147147
_didClose() {
148+
this._frameManager.dispose();
148149
assert(this._closedState !== 'closed', 'Page closed twice');
149150
this._closedState = 'closed';
150151
this.emit(Events.Page.Close);
151152
this._closedCallback();
152153
}
153154

154155
_didCrash() {
156+
this._frameManager.dispose();
155157
this.emit(Events.Page.Crash);
156158
this._crashedCallback(new Error('Page crashed'));
157159
}
158160

159161
_didDisconnect() {
162+
this._frameManager.dispose();
160163
assert(!this._disconnected, 'Page disconnected twice');
161164
this._disconnected = true;
162165
this._disconnectedCallback(new Error('Page closed'));

0 commit comments

Comments
 (0)