Skip to content

[Bug]: Browser Control Server hangs on /start endpoint (x64 Ubuntu) #3941

Closed as not planned

Description

@AlbertoSpain

Summary

Browser control server hangs indefinitely when receiving POST requests to /start endpoint, causing timeout errors despite the server being active and responding to other requests.

Steps to reproduce

  1. Install Clawdbot on Ubuntu 24.04 x64
  2. Configure browser with Playwright's Chromium:
    "browser": {
      "enabled": true,
      "defaultProfile": "clawd",
      "executablePath": "/home/user/.cache/ms-playwright/chromium-1208/chrome-linux64/chrome",
      "headless": true
    }
  3. Start gateway: clawdbot gateway start
  4. Attempt to use browser: browser.start()

Expected behavior

Browser should launch successfully in headless mode.

Actual behavior

  • Browser control server starts and listens on port 18791
  • Server responds to GET requests (e.g., curl http://127.0.0.1:18791/ returns 200 OK)
  • POST requests to /start hang indefinitely without any error logs
  • After 15 seconds, timeout error occurs: Can't reach the clawd browser control server at http://127.0.0.1:18791/start (timed out after 15000ms)

Environment

  • Clawdbot Version: 2026.1.24-3
  • OS: Ubuntu 24.04.1 LTS (x64)
  • Node.js: v22.22.0
  • Playwright: Chromium 145.0.7632.6 (installed via npx playwright install chromium)
  • Display: No X11 (SSH connection, headless mode required)

Additional context

  • Playwright works correctly when tested directly:
    const browser = await chromium.launch({
      executablePath: '/home/user/.cache/ms-playwright/chromium-1208/chrome-linux64/chrome',
      headless: true
    });
    // Works perfectly ✓
  • Browser control server logs show it starts successfully but no errors when it hangs
  • Similar to [Bug]: Browser Control Server Fails to Start on arm64 Ubuntu #2702 but on x64 instead of arm64
  • The /start endpoint specifically causes the hang - other endpoints respond

Logs

Gateway starts successfully:

{"subsystem":"browser/server"} Browser control listening on http://127.0.0.1:18791/

Tool call attempt:

{"subsystem":"agent/embedded"} embedded run tool start: tool=browser toolCallId=...
[tools] browser failed: Can't reach the clawd browser control server at http://127.0.0.1:18791/start (timed out after 15000ms)

No errors or exceptions logged during the hang.

Activity

  1. AlbertoSpain commented on Jan 29, 2026

    @AlbertoSpain
    Author

    Root Cause Analysis

    I've identified the exact source of this bug by analyzing the moltbot source code.

    The Problem

    The endpoint is synchronously blocking during Chrome launch, consuming the entire 15-second timeout without responding to the HTTP client.

    Location: src/browser/chrome.ts - launchClawdChrome() function (lines 201-205)

    const readyDeadline = Date.now() + 15_000;
    while (Date.now() < readyDeadline) {
      if (await isChromeReachable(profile.cdpUrl, 500)) break;
      await new Promise((r) => setTimeout(r, 200));
    }

    Call Chain

    1. Client calls POST /start → src/browser/routes/basic.ts (line ~93)
    2. Endpoint calls profileCtx.ensureBrowserAvailable() → src/browser/server-context.ts
    3. Which calls launchClawdChrome() → src/browser/chrome.ts
    4. Blocks here: Busy-wait loop checking if Chrome is reachable for up to 15 seconds
    5. If Chrome fails to start, loop consumes all 15 seconds before sending HTTP response
    6. Client timeout (also 15s) expires before server can respond with error

    Why Both Timeouts Collide

    • Server-side: 15-second busy-wait in launchClawdChrome()
    • Client-side: 15-second timeout in browser tool
    • Result: Client times out at ~15s, server finally responds with error at ~15s → timeout race condition

    The Fix

    The /start endpoint should:

    1. Respond immediately with { status: 'starting' }
    2. Launch Chrome in background
    3. Provide a separate endpoint to poll for ready state (e.g., GET /status with running field)

    Or alternatively:

    • Keep current synchronous approach but respond with progress updates (chunked response / SSE)
    • Reduce initial timeout to fail-fast (e.g., 5s) then return error immediately

    Related Code

    All relevant files in the browser subsystem:

    • src/browser/server.ts - HTTP server setup
    • src/browser/routes/basic.ts - Route handlers
    • src/browser/server-context.ts - Profile context and ensureBrowserAvailable()
    • src/browser/chrome.ts - The blocking loop in launchClawdChrome()

    This explains why GET requests work fine (no Chrome launch) but POST /start hangs (launches Chrome synchronously).

  2. AlbertoSpain commented on Jan 29, 2026

    @AlbertoSpain
    Author

    Update: Root Cause Confirmed + Workaround Found

    Confirmation

    Chrome does work on x64 Ubuntu when properly configured. The blocking timeout is definitely the root cause of the issue.

    The Missing Piece: noSandbox

    In headless environments without X11, Chrome requires:

    "browser": {
      "enabled": true,
      "noSandbox": true,
      "headless": true
    }

    Without noSandbox: true, Chrome fails silently in headless mode.

    Temporary Workaround

    I've patched the timeout locally to validate the fix:

    File: dist/browser/chrome.js (line ~203)

    // Original: const readyDeadline = Date.now() + 15_000;
    const readyDeadline = Date.now() + 10_000;  // Reduced to 10s

    With this change + noSandbox: true, browser now starts successfully:

    • Chrome launches in ~2-3 seconds
    • CDP ready and responding
    • Browser tool fully functional

    Why The Issue Still Matters

    Even though Chrome works with the right config, the synchronous blocking design is still a bug:

    1. Poor user experience: Client waits 10s with no feedback
    2. Fragile: Any delay in Chrome startup causes timeout
    3. No progress indication: User doesn't know if it's working or stuck
    4. Resource waste: Blocks Express worker thread during entire startup

    Recommended Fix

    As stated in the original analysis, /start should:

    1. Respond immediately with { status: 'starting', profile: '...' }
    2. Launch Chrome in background
    3. Let clients poll GET / (status endpoint) for running: true

    This pattern is standard for long-running operations in REST APIs.

  3. added
    bug
    on Jan 31, 2026
  4. openclaw-barnacle commented on Feb 14, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  5. added
    stale
    on Feb 14, 2026
  6. SichangHe commented on Feb 15, 2026

    @SichangHe

    No stale.

  7. removed
    stale
    on Feb 17, 2026
  8. openclaw-barnacle commented on Feb 24, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  9. added
    stale
    on Feb 24, 2026
  10. SichangHe commented on Feb 24, 2026

    @SichangHe

    g

  11. removed
    stale
    on Feb 25, 2026
  12. tbertran commented on Mar 1, 2026

    @tbertran

    #2702 is marked as a duplicate of this one but 2702 is on arm64 and this is on x64. Are we really sure it's the same issue @sebslight ?

  13. openclaw-barnacle commented on Mar 9, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  14. added
    stale
    on Mar 9, 2026
  15. openclaw-barnacle commented on Mar 15, 2026

    @openclaw-barnacle

    Closing due to inactivity.
    If this is still an issue, please retry on the latest OpenClaw release and share updated details.
    If you are absolutely sure it still happens on the latest release, open a new issue with fresh repro steps.

  16. locked as resolved and limited conversation to collaborators on Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugstale

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions