Skip to content

Fix automation window not closing on command failure#992

Merged
jackwener merged 1 commit intomainfrom
fix-window-close-on-error
Apr 13, 2026
Merged

Fix automation window not closing on command failure#992
jackwener merged 1 commit intomainfrom
fix-window-close-on-error

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

  • Add page.closeWindow() to the error path in executeCommand(), after diagnostic collection but before rethrowing
  • Previously, only the success path closed the automation window; failures relied on the extension's 30s idle timer (unreliable on Windows due to MV3 service worker suspension)

Root cause

The automation window lifecycle was only managed on the success path (execution.ts:226). On failure, the window was orphaned and depended on setTimeout in the extension's service worker — which Chrome can suspend before the callback fires, especially on Windows.

Changes

  • src/execution.ts: Add closeWindow call in catch block (after diagnostic, before throw)
  • src/execution.test.ts: Add regression test verifying closeWindow is called on browser command failure

Test plan

  • New test: calls closeWindow on browser command failure passes
  • All 197 test files pass (1491 tests)

The error path in executeCommand did not call page.closeWindow(),
leaving the automation window open until the extension's idle timer
fires. On Windows, MV3 service worker suspension makes this timer
unreliable, causing windows to linger indefinitely.

Now closeWindow is called after diagnostic collection but before
rethrowing, ensuring the window is closed on both success and failure.
@jackwener jackwener merged commit ff6563d into main Apr 13, 2026
13 checks passed
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.

1 participant