Skip to content

Commit

Permalink
chore: don't run destroyHandles if realm is already disposed (#12365)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade committed Apr 30, 2024
1 parent 41d4320 commit 3103744
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/puppeteer-core/src/api/Realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ export abstract class Realm implements Disposable {

#disposed = false;
/** @internal */
[disposeSymbol](): void {
dispose(): void {
this.#disposed = true;
this.taskManager.terminateAll(
new Error('waitForFunction failed: frame got detached.')
);
}
/** @internal */
[disposeSymbol](): void {
this.dispose();
}
}
5 changes: 5 additions & 0 deletions packages/puppeteer-core/src/bidi/Realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export abstract class BidiRealm extends Realm {
protected initialize(): void {
this.realm.on('destroyed', ({reason}) => {
this.taskManager.terminateAll(new Error(reason));
this.dispose();
});
this.realm.on('updated', () => {
this.internalPuppeteerUtil = undefined;
Expand Down Expand Up @@ -224,6 +225,10 @@ export abstract class BidiRealm extends Realm {
}

async destroyHandles(handles: Array<BidiJSHandle<unknown>>): Promise<void> {
if (this.disposed) {
return;
}

const handleIds = handles
.map(({id}) => {
return id;
Expand Down

0 comments on commit 3103744

Please sign in to comment.