Skip to content

browser_navigate retry loop spawns multiple about:blank tabs when profile is locked #1311

@reichenbach

Description

@reichenbach

Environment

  • OS: macOS 14.x
  • Playwright MCP: latest (via npx @playwright/mcp@latest)
  • Client: Claude Code

Describe the bug

When the browser profile is already in use (e.g., Chrome wasn't fully killed from a previous session), browser_navigate enters a retry loop that spawns 5+ about:blank tabs before finally throwing the "Browser is already in use" error.

To Reproduce

  1. Start a Playwright MCP session, navigate to a page
  2. Kill the MCP client without calling browser_close (simulating a crash or forced quit)
  3. Start a new MCP session and call browser_navigate
  4. Observe: 5-6 about:blank tabs open in rapid succession before the error is thrown

Expected behavior

The MCP should check if the profile is available before attempting to launch a browser instance. If locked, fail immediately with a clear error - don't retry in a loop that creates visible side effects.

Current behavior

The retry loop in browserContextFactory.ts catches ProcessSingleton/exitCode=21 errors and retries up to 5 times. Each retry appears to spawn a new tab before failing, resulting in multiple about:blank tabs.

Suggested fix

  1. Pre-flight check for Chrome's SingletonLock file before launching
  2. If lock exists, check if the owning PID is still alive (stale lock detection)
  3. Fail fast with actionable error instead of retry loop

Workaround

Kill all Chrome processes before starting a new session:

pkill -9 -f "Chromium" 2>/dev/null || true
pkill -9 -f "chrome" 2>/dev/null || true

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions