chore: don't run destroyHandles if realm is already disposed (#12365)

This commit is contained in:
Nikolay Vitkov 2024-04-30 07:59:07 +02:00 committed by GitHub
parent 41d43200b7
commit 3103744a67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -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();
}
}

View File

@ -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;
@ -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;