openclaw - ✅(Solved) Fix [Bug]: browser stop does not disconnect Playwright CDP session for attachOnly profiles [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#60095Fetched 2026-04-08 02:36:24
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
referenced ×3closed ×1cross-referenced ×1locked ×1

Root Cause

In createProfileAvailability() (routes-GmL6Gsmc.js), the stopRunningBrowser function checks profileState.running — which is null for attachOnly profiles (since no browser process was launched). When !profileState.running, it returns { stopped: false } immediately without calling closePlaywrightBrowserConnectionForProfile().

// Current code (broken for attachOnly)
const stopRunningBrowser = async () => {
    await reconcileProfileRuntime();
    if (capabilities.usesChromeMcp) return { stopped: await closeChromeMcpSession(profile.name) };
    const profileState = getProfileState();
    if (!profileState.running) return { stopped: false }; // ← early return, no cleanup
    await stopOpenClawChrome(profileState.running);
    setProfileRunning(null);
    return { stopped: true };
};

Compare with resetProfile() in createProfileResetOps(), which does call closePlaywrightBrowserConnectionForProfile() regardless of profileState.running — and correctly releases the connection.

Fix Action

Fix / Workaround

Applied the patch locally to routes-GmL6Gsmc.js. After browser stop, refreshing the page correctly restores prefers-color-scheme to system value (dark mode).

PR fix notes

PR #60097: fix(browser): disconnect Playwright CDP session on stop for attachOnly profiles

Description (problem / solution / changelog)

Fixes #60095

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • extensions/browser/src/browser/server-context.availability.ts (modified, +8/-0)
  • extensions/browser/src/browser/server-context.stop-running-browser.test.ts (added, +132/-0)

Code Example

// Current code (broken for attachOnly)
const stopRunningBrowser = async () => {
    await reconcileProfileRuntime();
    if (capabilities.usesChromeMcp) return { stopped: await closeChromeMcpSession(profile.name) };
    const profileState = getProfileState();
    if (!profileState.running) return { stopped: false }; // ← early return, no cleanup
    await stopOpenClawChrome(profileState.running);
    setProfileRunning(null);
    return { stopped: true };
};

---

const stopRunningBrowser = async () => {
    await reconcileProfileRuntime();
    if (capabilities.usesChromeMcp) return { stopped: await closeChromeMcpSession(profile.name) };
    const profileState = getProfileState();
    if (!profileState.running) {
        await closePlaywrightBrowserConnectionForProfile(profile.cdpUrl);
        return { stopped: true };
    }
    await stopOpenClawChrome(profileState.running);
    setProfileRunning(null);
    return { stopped: true };
};
RAW_BUFFERClick to expand / collapse

Bug Description

browser stop (action=stop) does not disconnect the Playwright CDP connection for attachOnly profiles. The Playwright connectOverCDP session remains active until the gateway is restarted.

Impact

  • prefers-color-scheme override persists — Playwright attach resets emulated media features (e.g., dark mode → light mode). Since the connection is never released, refreshing the page does not restore the system theme.
  • Other CDP side effects persist — viewport overrides, navigator.webdriver, etc. remain until gateway restart.
  • No clean detach path — users must restart the entire gateway just to release a browser profile connection.

Root Cause

In createProfileAvailability() (routes-GmL6Gsmc.js), the stopRunningBrowser function checks profileState.running — which is null for attachOnly profiles (since no browser process was launched). When !profileState.running, it returns { stopped: false } immediately without calling closePlaywrightBrowserConnectionForProfile().

// Current code (broken for attachOnly)
const stopRunningBrowser = async () => {
    await reconcileProfileRuntime();
    if (capabilities.usesChromeMcp) return { stopped: await closeChromeMcpSession(profile.name) };
    const profileState = getProfileState();
    if (!profileState.running) return { stopped: false }; // ← early return, no cleanup
    await stopOpenClawChrome(profileState.running);
    setProfileRunning(null);
    return { stopped: true };
};

Compare with resetProfile() in createProfileResetOps(), which does call closePlaywrightBrowserConnectionForProfile() regardless of profileState.running — and correctly releases the connection.

Proposed Fix

const stopRunningBrowser = async () => {
    await reconcileProfileRuntime();
    if (capabilities.usesChromeMcp) return { stopped: await closeChromeMcpSession(profile.name) };
    const profileState = getProfileState();
    if (!profileState.running) {
        await closePlaywrightBrowserConnectionForProfile(profile.cdpUrl);
        return { stopped: true };
    }
    await stopOpenClawChrome(profileState.running);
    setProfileRunning(null);
    return { stopped: true };
};

Steps to Reproduce

  1. Configure a browser profile with attachOnly: true and cdpPort pointing to an externally launched browser (e.g., Arc with --remote-debugging-port=9222)
  2. Run browser snapshot or browser navigate (this establishes the Playwright CDP connection)
  3. Run browser stop — observe that status still shows running: true and Playwright emulation overrides persist
  4. Refresh a page in the browser — prefers-color-scheme is still overridden (light instead of system dark)
  5. Only gateway restart releases the connection

Environment

  • OpenClaw 2026.3.31 (213a704)
  • macOS (Apple Silicon)
  • Arc browser with --remote-debugging-port=9222
  • Profile config: browser.profiles.user = { cdpPort: 9222, attachOnly: true }

Verified Fix

Applied the patch locally to routes-GmL6Gsmc.js. After browser stop, refreshing the page correctly restores prefers-color-scheme to system value (dark mode).

extent analysis

TL;DR

The proposed fix involves modifying the stopRunningBrowser function to call closePlaywrightBrowserConnectionForProfile when profileState.running is null, ensuring the Playwright CDP connection is released for attachOnly profiles.

Guidance

  • Review the stopRunningBrowser function in routes-GmL6Gsmc.js to ensure it correctly handles attachOnly profiles by calling closePlaywrightBrowserConnectionForProfile when profileState.running is null.
  • Verify that the closePlaywrightBrowserConnectionForProfile function is correctly implemented and releases the Playwright CDP connection.
  • Test the fix by running the steps to reproduce and observing that the prefers-color-scheme override is correctly released after running browser stop.
  • Consider reviewing other parts of the codebase to ensure similar issues are not present in other functions.

Example

const stopRunningBrowser = async () => {
    // ...
    if (!profileState.running) {
        await closePlaywrightBrowserConnectionForProfile(profile.cdpUrl);
        return { stopped: true };
    }
    // ...
};

Notes

The proposed fix assumes that the closePlaywrightBrowserConnectionForProfile function is correctly implemented and releases the Playwright CDP connection. If this function is not correctly implemented, additional debugging may be necessary.

Recommendation

Apply the proposed fix to the stopRunningBrowser function to ensure the Playwright CDP connection is released for attachOnly profiles, as it correctly addresses the issue and has been verified to work.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: browser stop does not disconnect Playwright CDP session for attachOnly profiles [1 pull requests, 1 participants]