From 865eaf6f2b4a991798aa56db3230d2f891b0bebf Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Fri, 14 Aug 2026 19:22:00 -0700 Subject: [PATCH] fix(browse): guard browser.process() in resolveDisconnectCause `.process()` only exists on browsers Playwright launched itself; a browser from connectOverCDP() (or a test stub) has no such method, so the blind call threw "browser?.process is not a function" inside the disconnect handler and took down the daemon. Type-check the method before calling it and treat the no-method case as no process handle. Closes #2085. Contributed by @elan2002 (PR #2434). Co-Authored-By: Claude Fable 5 --- browse/src/browser-manager.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/browse/src/browser-manager.ts b/browse/src/browser-manager.ts index 203fc88c4..255f6b583 100644 --- a/browse/src/browser-manager.ts +++ b/browse/src/browser-manager.ts @@ -91,7 +91,11 @@ export function shouldEnableChromiumSandbox(): boolean { * restarts on backoff. */ export async function resolveDisconnectCause(browser: Browser | null): Promise<'clean' | 'crash'> { - const proc = browser?.process(); + // `.process()` only exists on browsers we launched ourselves. A browser + // obtained via connectOverCDP() (or a stub in tests) has no such method — + // calling it blind throws inside the disconnect handler, which killed the + // whole daemon with "browser?.process is not a function". + const proc = typeof browser?.process === 'function' ? browser.process() : null; if (proc && proc.exitCode === null && proc.signalCode === null) { await new Promise((resolve) => { const timer = setTimeout(resolve, 1000);