chore(electron): don't swallow close errors (#31509)

This commit is contained in:
Max Schmitt 2024-07-01 22:00:03 +02:00 committed by GitHub
parent f62121548a
commit 9dc7e40084
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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