Skip to content

fix: launchpad correctly refelct browser state after browser closed#34179

Open
emilyrohrbough wants to merge 2 commits into
developfrom
launchpad-shows-when-browser-closes
Open

fix: launchpad correctly refelct browser state after browser closed#34179
emilyrohrbough wants to merge 2 commits into
developfrom
launchpad-shows-when-browser-closes

Conversation

@emilyrohrbough

@emilyrohrbough emilyrohrbough commented Jun 29, 2026

Copy link
Copy Markdown
Member

Additional details


Note

Low Risk
Scoped to interactive open mode browser lifecycle; run mode behavior on open failure is unchanged (still throws).

Overview
Fixes #23798 where cypress open Launchpad could still show the browser as open after the user closed it, blocking relaunch until an extra Close click.

In packages/server/lib/browsers/index.ts, open mode (!ctx.isRunMode) now resets app browser state when launch or runtime close paths do not always fire exit: onError is wrapped so a non-closed status becomes closed and onBrowserClose runs (covers macOS Chrome closing the window while the process stays alive); browserLauncher.open is in try/catch so failures set closed, invoke onBrowserClose, call clearInstanceState, and return null instead of leaving an opening spinner—run mode still rethrows.

cli/CHANGELOG.md documents the fix under 15.18.1. Unit tests in browsers_spec.ts cover open-mode open failure, run-mode rethrow, and onError reset.

Reviewed by Cursor Bugbot for commit 3ec6417. Bugbot is set up for automated code reviews on this repo. Configure here.

Steps to test

yarn dev from repo root, then open a project with both E2E and component testing configured. Use Chrome and Chrome Beta — these are the browsers named in the issue.


Scenario 1 — Chrome closes after fully opening (the primary bug)

Verifies: exit event path, already worked

  1. Open launchpad, select Chrome, click Start E2E Testing
  2. Wait for Chrome to fully open (status reaches 'open', browser list is greyed with Focus/Close buttons showing)
  3. Quit Chrome via ⌘Q
  4. Expected: Launchpad immediately re-focuses and resets to the browser selection screen with the Launch button active
  5. Not expected: Browser list stays greyed out

Scenario 2 — Chrome window closed during startup (Scenario A fix)

Verifies: try/catch around browserLauncher.open()

  1. Open launchpad, select Electron, click Start E2E Testing
  2. Immediately after the Electron window appears (within ~1 second), close it with ⌘W
  3. Expected: Launchpad resets to the browser selection screen with Launch button active; no frozen "Opening…" spinner
  4. Not expected: Spinner stays indefinitely

Repeat with Chrome — it's harder to time but try closing Chrome immediately after the window opens before Cypress finishes loading.


Scenario 3 — Chrome window closed with X button / ⌘W on macOS (Scenario B fix)

Verifies: onError wrapper for the macOS "process stays alive" case

  1. Open launchpad, select Chrome, click Start E2E Testing
  2. Wait for Chrome to fully open
  3. Close the Chrome window using the red X button (or ⌘W) — do not use ⌘Q
  4. On macOS, Chrome may keep its process running (dock icon visible)
  5. Expected: Launchpad resets to browser selection screen with Launch button active
  6. Not expected: Browser list stays greyed out showing the browser as still open

Scenario 4 — Relaunch after window-close reset (regression for the fix)

Verifies: instance survives so kill() can clean up on relaunch

  1. Complete Scenario 3 (close Chrome window with X, launchpad resets)
  2. Click Launch again from the launchpad
  3. Expected: Chrome opens cleanly; no "another Chrome is running" error, no profile lock issue
  4. Not expected: Error launching browser, or Cypress spawning a second Chrome alongside an existing one

Scenario 5 — Normal close via launchpad button (regression)

Verifies: existing "Close Browser" button path is unaffected

  1. Open launchpad, select Chrome, click Start E2E Testing
  2. Wait for Chrome to fully open
  3. Click the Close Browser button in the launchpad
  4. Expected: Chrome closes and launchpad resets to browser selection — same as before the fix

PR Tasks

  • Is there an associated issue with maintainer approval for PR submission?
  • Have tests been added/updated?
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?

cypress-bot[bot]
cypress-bot Bot previously approved these changes Jun 29, 2026
@emilyrohrbough emilyrohrbough requested a review from davidr-cy June 29, 2026 17:29
@cypress-bot cypress-bot Bot dismissed their stale review June 29, 2026 17:29

Cursor Bugbot risk assessment is no longer Low Risk. Auto-approval dismissed; manual review required.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3ec6417. Configure here.

if (ctx.isRunMode) throw err

return null
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delay overwrites closed browser status

High Severity

In open mode, the new onError wrapper can set browserStatus to closed and invoke onBrowserClose while browsers.open is still in its post-launch wait. The function only checks whether instance is null before calling onBrowserOpen and setting status to open, so a window closed during that window can be reported as open again.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3ec6417. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Closed Chrome Browser Isn't Reflected in Launchpad

1 participant