chore(electron): don't swallow close errors (#31509)
This commit is contained in:
parent
f62121548a
commit
9dc7e40084
|
|
@ -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> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue