Skip to content

[Bug]: _electron.launch intermittently loses a packaged app's first window since 1.64.0 #43247

Open

Description

Version

1.64.0 (regression from 1.63.0)

Steps to reproduce

  1. Package an Electron app (we're on Electron 44.5.1) whose ready handler creates a hidden BrowserWindow and only calls loadURL on it after an await:

    app.on("ready", async () => {
      const win = new BrowserWindow({ show: false, title: "My App" });
      await new Promise((r) => setTimeout(r, 1000));
      await win.loadURL(`file://${__dirname}/index.html`);
      win.once("ready-to-show", () => win.show());
    });
  2. Launch the packaged executable (packaged with @electron/packager) and wait for the window:

    const app = await electron.launch({ executablePath: "/path/to/packaged/app" });
    const page = await app.firstWindow();

Expected behavior

The window is reported in app.windows() / firstWindow(), as in 1.63.0.

Actual behavior

Intermittently, the window is never reported. app.windows() stays empty and firstWindow() times out, while the app itself is running normally. In our CI, the packaged app running is running in mcr.microsoft.com/playwright:v1.64.0.

Additional context

Likely cause: #43075, the follow-up to #42936.

  • For packaged apps, electron.ts does not inject loader.js, so the ready event is not deferred until __playwright_run(). The app creates its windows while CRBrowser.connect is still running with _isConnecting = true.
  • Since chore(chromium): close pages that crashed before connecting over CDP #43075, Inspector.enable is sent to every page attached while _isConnecting, and _onTargetCrashed closes and removes any page that is not yet initialized.
  • A hidden BrowserWindow that has not navigated yet has no renderer, so it is treated as crashed and dropped. Its target stays attached, so it is never reported again, even after it navigates.

#42936 explicitly noted that "a new page might not have a renderer yet, e.g. an Electron window before its first navigation, and must not be treated as crashed". Its CI caught the Electron firstWindow delayed-navigation test timing out, and the fix limited the check to pre-existing pages. #43075 widened the condition to _isConnecting. Playwright's Electron tests launch unpackaged apps, where the loader defers ready until after connecting, so they don't cover this path.

Environment

System: Ubuntu 24.04 (mcr.microsoft.com/playwright:v1.64.0), GitHub Actions ubuntu-latest
Node: 24.21.0
Electron: 44.5.1 (packaged app using @electron/packager, launched via executablePath)
@playwright/test: 1.64.0

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions