Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix: retry browser launch if it failed due to glibc error (#5247)
Andrey Lushnikov276bbca3d141
diff --git a/src/server/browserType.ts b/src/server/browserType.tsindex db6ed75572..0056074326 100644--- a/src/server/browserType.ts+++ b/src/server/browserType.ts@@ -66,7 +66,7 @@ export abstract class BrowserType {const controller = new ProgressController();controller.setLogName('browser');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));return browser;}@@ -77,11 +77,25 @@ export abstract class BrowserType {const controller = new ProgressController();controller.setLogName('browser');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));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> {options.proxy = options.proxy ? normalizeProxySettings(options.proxy) : undefined;const browserLogsCollector = new RecentLogsCollector();