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(electron): flaky startup if stderr comes in too fast (#30855)
Joel Einbinderd0644f5444a0
diff --git a/packages/playwright-core/src/server/electron/electron.ts b/packages/playwright-core/src/server/electron/electron.tsindex 9b934ca2f7..b8f361b48a 100644--- a/packages/playwright-core/src/server/electron/electron.ts+++ b/packages/playwright-core/src/server/electron/electron.ts@@ -229,6 +229,8 @@ export class Electron extends SdkObject {onExit: () => app?.emit(ElectronApplication.Events.Close),});+ // All waitForLines must be started immediately.+ // Otherwise the lines might come before we are ready.const waitForXserverError = new Promise(async (resolve, reject) => {waitForLine(progress, launchedProcess, /Unable to open X display/).then(() => reject(new Error(['Unable to open X display!',@@ -240,17 +242,20 @@ export class Electron extends SdkObject {progress.metadata.log].join('\n')))).catch(() => {});});+ const nodeMatchPromise = waitForLine(progress, launchedProcess, /^Debugger listening on (ws:\/\/.*)$/);+ const chromeMatchPromise = waitForLine(progress, launchedProcess, /^DevTools listening on (ws:\/\/.*)$/);+ const debuggerDisconnectPromise = waitForLine(progress, launchedProcess, /Waiting for the debugger to disconnect\.\.\./);- const nodeMatch = await waitForLine(progress, launchedProcess, /^Debugger listening on (ws:\/\/.*)$/);+ const nodeMatch = await nodeMatchPromise;const nodeTransport = await WebSocketTransport.connect(progress, nodeMatch[1]);const nodeConnection = new CRConnection(nodeTransport, helper.debugProtocolLogger(), browserLogsCollector);// Immediately release exiting process under debug.- waitForLine(progress, launchedProcess, /Waiting for the debugger to disconnect\.\.\./).then(() => {+ debuggerDisconnectPromise.then(() => {nodeTransport.close();}).catch(() => {});const chromeMatch = await Promise.race([- waitForLine(progress, launchedProcess, /^DevTools listening on (ws:\/\/.*)$/),+ chromeMatchPromise,waitForXserverError,]) as RegExpMatchArray;const chromeTransport = await WebSocketTransport.connect(progress, chromeMatch[1]);