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.
This commit is contained in:
ShawnPana 2026-03-11 11:54:44 -07:00
parent a3fdb664d2
commit 74177d480e

View File

@ -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({