fix: retry browser launch if it failed due to glibc error (#5247)
Fixes #5214
This commit is contained in:
parent
198e403c14
commit
276bbca3d1
|
|
@ -66,7 +66,7 @@ export abstract class BrowserType {
|
||||||
const controller = new ProgressController();
|
const controller = new ProgressController();
|
||||||
controller.setLogName('browser');
|
controller.setLogName('browser');
|
||||||
const browser = await controller.run(progress => {
|
const browser = await controller.run(progress => {
|
||||||
return this._innerLaunch(progress, options, undefined, helper.debugProtocolLogger(protocolLogger)).catch(e => { throw this._rewriteStartupError(e); });
|
return this._innerLaunchWithRetries(progress, options, undefined, helper.debugProtocolLogger(protocolLogger)).catch(e => { throw this._rewriteStartupError(e); });
|
||||||
}, TimeoutSettings.timeout(options));
|
}, TimeoutSettings.timeout(options));
|
||||||
return browser;
|
return browser;
|
||||||
}
|
}
|
||||||
|
|
@ -77,11 +77,25 @@ export abstract class BrowserType {
|
||||||
const controller = new ProgressController();
|
const controller = new ProgressController();
|
||||||
controller.setLogName('browser');
|
controller.setLogName('browser');
|
||||||
const browser = await controller.run(progress => {
|
const browser = await controller.run(progress => {
|
||||||
return this._innerLaunch(progress, options, persistent, helper.debugProtocolLogger(), userDataDir).catch(e => { throw this._rewriteStartupError(e); });
|
return this._innerLaunchWithRetries(progress, options, persistent, helper.debugProtocolLogger(), userDataDir).catch(e => { throw this._rewriteStartupError(e); });
|
||||||
}, TimeoutSettings.timeout(options));
|
}, TimeoutSettings.timeout(options));
|
||||||
return browser._defaultContext!;
|
return browser._defaultContext!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _innerLaunchWithRetries(progress: Progress, options: types.LaunchOptions, persistent: types.BrowserContextOptions | undefined, protocolLogger: types.ProtocolLogger, userDataDir?: string): Promise<Browser> {
|
||||||
|
try {
|
||||||
|
return this._innerLaunch(progress, options, persistent, protocolLogger, userDataDir);
|
||||||
|
} catch (error) {
|
||||||
|
// @see https://github.com/microsoft/playwright/issues/5214
|
||||||
|
const errorMessage = typeof error === 'object' && typeof error.message === 'string' ? error.message : '';
|
||||||
|
if (errorMessage.includes('Inconsistency detected by ld.so')) {
|
||||||
|
progress.log(`<restarting browser due to hitting race condition in glibc>`);
|
||||||
|
return this._innerLaunch(progress, options, persistent, protocolLogger, userDataDir);
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async _innerLaunch(progress: Progress, options: types.LaunchOptions, persistent: types.BrowserContextOptions | undefined, protocolLogger: types.ProtocolLogger, userDataDir?: string): Promise<Browser> {
|
async _innerLaunch(progress: Progress, options: types.LaunchOptions, persistent: types.BrowserContextOptions | undefined, protocolLogger: types.ProtocolLogger, userDataDir?: string): Promise<Browser> {
|
||||||
options.proxy = options.proxy ? normalizeProxySettings(options.proxy) : undefined;
|
options.proxy = options.proxy ? normalizeProxySettings(options.proxy) : undefined;
|
||||||
const browserLogsCollector = new RecentLogsCollector();
|
const browserLogsCollector = new RecentLogsCollector();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue