From 51c1ca502398eb19dcafaa99aa1f59c03cbb6536 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 31 May 2026 09:33:31 -0700 Subject: [PATCH] fix: unref browser grab timeout (#4247) --- src/main/browser/browser-grab-session-controller.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/browser/browser-grab-session-controller.ts b/src/main/browser/browser-grab-session-controller.ts index fafef11c2..f810a3a74 100644 --- a/src/main/browser/browser-grab-session-controller.ts +++ b/src/main/browser/browser-grab-session-controller.ts @@ -188,6 +188,11 @@ export class BrowserGrabSessionController { const timeoutId = setTimeout(() => { settleOnce({ opId, kind: 'cancelled', reason: 'timeout' }) }, GRAB_OP_TIMEOUT_MS) + // Why: the timeout prevents stale grab state, but an armed grab should + // not keep Electron main alive after its owning tab/window is gone. + if (typeof timeoutId.unref === 'function') { + timeoutId.unref() + } guest.on('did-start-navigation', handleNavigation) guest.on('destroyed', handleDestroyed)