From 74177d480e266bea2644dce2709555a4e04eb2a9 Mon Sep 17 00:00:00 2001 From: ShawnPana Date: Wed, 11 Mar 2026 11:54:44 -0700 Subject: [PATCH] browser: return accurate stop status for remote WebSocket profiles Check hasActivePlaywrightConnection before closing so repeated or cold-start stop calls correctly return { stopped: false } instead of always claiming a session was terminated. --- src/browser/server-context.availability.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/browser/server-context.availability.ts b/src/browser/server-context.availability.ts index 5afcec8be1c..bea8c54b33e 100644 --- a/src/browser/server-context.availability.ts +++ b/src/browser/server-context.availability.ts @@ -260,8 +260,9 @@ export function createProfileAvailability({ // For remote WebSocket endpoints (e.g. Browser Use), there's no local Chrome process // to stop. Instead, close the cached Playwright connection to the cloud provider. if (capabilities.isRemote && isWebSocketUrl(profile.cdpUrl)) { + const wasConnected = hasActivePlaywrightConnection(profile.cdpUrl); await closePlaywrightBrowserConnection({ cdpUrl: profile.cdpUrl }); - return { stopped: true }; + return { stopped: wasConnected }; } if (capabilities.requiresRelay) { const stopped = await stopChromeExtensionRelayServer({