Repository navigation
Description
Feature Request
Is your feature request related to a problem?
electronApp.close() currently waits indefinitely for the Electron process to exit. If the application has before-quit handlers that prevent shutdown, leaky IPC handlers, or child processes that keep it alive, close() hangs forever until the test-level timeout kills everything.
This is a well-documented pain point:
- [Question] Call app.quit() in Electron but process sticks around #12189 —
app.quit()called but process sticks around - [REGRESSION]: electron tests sometimes freezes for 30 seconds #27523 — Electron tests freeze 30s on close
- [Bug]: Leaky Electron IPC handlers cause tests to hang on Linux/Windows #39248 — Leaky IPC handlers cause hangs on Linux/Windows
- [BUG] - Electron hangs closing the context #13874 — Electron hangs closing context
PR #11336 rightfully removed the old hardcoded 30s timeout (which was inconsistent with other close() methods). But now there is no way for users to specify a grace period with force-kill escalation.
The force-kill infrastructure already exists in processLauncher.ts (killProcess() → SIGKILL / taskkill /T /F) but is only reachable via OS signals (SIGINT/SIGTERM), not through the public close() API.
Describe the solution
Add an opt-in timeout option to electronApp.close():
// Default: wait forever (unchanged behavior)
await electronApp.close();
// With timeout: force-kill if app does not exit within 10s
await electronApp.close({ timeout: 10_000 });When specified:
- Initiate graceful shutdown (existing flow:
browser.close()→app.quit()→worker._disconnect()) - Start a timer
- If the process exits within the timeout, clear the timer (no force-kill)
- If the timer fires first, call the existing
kill()fromprocessLauncher(SIGKILL/taskkill) - Wait for the process to fully exit
This is different from the removed behavior (#11336) because:
- Opt-in: no timeout by default (backward compatible)
- Force-kills instead of throwing: the old timeout threw an error and left the process running
- Uses existing infrastructure: wires the
killfunction fromlaunchProcessintoElectronApplication
Real-world use case
We maintain E2E tests for a VS Code extension using Playwright Electron. Our test teardown was flaky because close() would occasionally hang when the Electron app did not exit cleanly. We had to build a 3-layer workaround: app.quit() → app.close() wrapped in Promise.race with manual timer → SIGKILL fallback. This feature would replace that pattern with a single API call.
I have a PR ready if you are open to this.
Activity
pavelfeldman commentedon Oct 31, 2026
We're closing all
P3-collecting-feedbackissues and retiring the label. #43813 explains why. This doesn't mean the request is wrong. If it still matters to you, please open a new issue against the latest Playwright version with your concrete use case and link back here.