chore(electron): don't swallow close errors

This commit is contained in:
Max Schmitt 2024-07-01 20:59:46 +02:00
parent 9a3e0967e6
commit 4f1d212d3e

View file

@ -29,7 +29,7 @@ import type { Page } from './page';
import { ConsoleMessage } from './consoleMessage';
import type { Env, WaitForEventOptions, Headers, BrowserContextOptions } from './types';
import { Waiter } from './waiter';
import { TargetClosedError } from './errors';
import { TargetClosedError, isTargetClosedError } from './errors';
type ElectronOptions = Omit<channels.ElectronLaunchOptions, 'env'|'extraHTTPHeaders'|'recordHar'|'colorScheme'|'acceptDownloads'> & {
env?: Env,
@ -116,7 +116,13 @@ export class ElectronApplication extends ChannelOwner<channels.ElectronApplicati
}
async close() {
await this._context.close().catch(() => {});
try {
await this._context.close();
} catch (e) {
if (isTargetClosedError(e))
return;
throw e;
}
}
async waitForEvent(event: string, optionsOrPredicate: WaitForEventOptions = {}): Promise<any> {