Skip to content

fix(browser): include Chrome stderr and sandbox hint in CDP startup error#29355

Merged
vincentkoc merged 5 commits intoopenclaw:mainfrom
veast:fix/browser-cdp-startup-diagnostics
Mar 2, 2026
Merged

fix(browser): include Chrome stderr and sandbox hint in CDP startup error#29355
vincentkoc merged 5 commits intoopenclaw:mainfrom
veast:fix/browser-cdp-startup-diagnostics

Conversation

@veast
Copy link
Contributor

@veast veast commented Feb 28, 2026

Problem

When Chrome fails to start and CDP times out on port 18800 (or any configured port), the error message is:

Failed to start Chrome CDP on port 18800 for profile "openclaw".

This gives users zero diagnostic information. They cannot tell if the issue is:

  • Chrome crashing due to missing --no-sandbox in a container/root environment
  • Shared memory (/dev/shm) too small
  • A GPU/display issue
  • A port conflict
  • Something else entirely

This was reported in #29312 where Chrome worked fine when launched manually but failed through OpenClaw.

Fix

  • Collect Chrome's stderr output and include up to 2000 chars in the error message
  • On Linux, if browser.noSandbox is not enabled, append a hint suggesting the user try browser.noSandbox: true (common fix for containers and root environments)

Example output after fix

Failed to start Chrome CDP on port 18800 for profile "openclaw".
Hint: If running in a container or as root, try setting browser.noSandbox: true in config.
Chrome stderr:
[0228/103456.789:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported...

Testing

  • Existing browser tests unchanged (no behavioral change when Chrome starts successfully)
  • On failure, error now includes actionable diagnostics

Closes #29312

…rror (openclaw#29312)

When Chrome fails to start and CDP times out, the error message previously
contained no diagnostic information, making it impossible to determine why
Chrome couldn't start (e.g. missing --no-sandbox in containers, GPU issues,
shared memory errors).

This change:
- Collects Chrome's stderr output and includes up to 2000 chars in the error
- On Linux, if noSandbox is not set, appends a hint to try browser.noSandbox: true

Closes openclaw#29312
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fe6e1cee40

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 28, 2026

Greptile Summary

This PR improves error diagnostics when Chrome fails to start through CDP by collecting stderr output and providing actionable hints.

Key changes:

  • Captures Chrome's stderr output during the startup phase (limited to 2000 chars to prevent excessive output)
  • Includes stderr in the error message when CDP fails to start within the 15-second timeout
  • Adds a Linux-specific hint suggesting browser.noSandbox: true when running in containers or as root (only shown when noSandbox is not already enabled)

Analysis:

  • No behavioral changes to the success path - existing functionality remains untouched
  • Proper use of optional chaining (proc.stderr?.on) to handle cases where stderr might be undefined
  • Memory-bounded stderr collection prevents potential memory issues
  • Error message construction is clean with conditional hints that only appear when relevant

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The change is purely additive for error diagnostics without modifying any existing logic paths. The implementation properly handles edge cases (undefined stderr, empty output) and bounds memory usage. No tests need updating because the happy path behavior is unchanged.
  • No files require special attention

Last reviewed commit: fe6e1ce

vincentkoc and others added 4 commits March 1, 2026 22:19
…emory leak

Named the anonymous listener so it can be removed via proc.stderr.off()
once CDP is confirmed reachable. Also clears the stderrChunks array on
success so the buffered data is eligible for GC.

Fixes the unbounded memory growth reported in code review: a long-lived
Chrome process emitting periodic warnings would keep appending to
stderrChunks indefinitely since the listener was never removed.

Addresses review comment from chatgpt-codex-connector on PR openclaw#29355.
@vincentkoc vincentkoc merged commit 281494a into openclaw:main Mar 2, 2026
26 checks passed
@vincentkoc vincentkoc mentioned this pull request Mar 2, 2026
16 tasks
robertchang-ga pushed a commit to robertchang-ga/openclaw that referenced this pull request Mar 2, 2026
…rror (openclaw#29355)

* fix(browser): include Chrome stderr and sandbox hint in CDP startup error (openclaw#29312)

When Chrome fails to start and CDP times out, the error message previously
contained no diagnostic information, making it impossible to determine why
Chrome couldn't start (e.g. missing --no-sandbox in containers, GPU issues,
shared memory errors).

This change:
- Collects Chrome's stderr output and includes up to 2000 chars in the error
- On Linux, if noSandbox is not set, appends a hint to try browser.noSandbox: true

Closes openclaw#29312

* chore(browser): format chrome startup diagnostics

* fix(browser): detach stderr listener after Chrome starts to prevent memory leak

Named the anonymous listener so it can be removed via proc.stderr.off()
once CDP is confirmed reachable. Also clears the stderrChunks array on
success so the buffered data is eligible for GC.

Fixes the unbounded memory growth reported in code review: a long-lived
Chrome process emitting periodic warnings would keep appending to
stderrChunks indefinitely since the listener was never removed.

Addresses review comment from chatgpt-codex-connector on PR openclaw#29355.

* changelog: note cdp startup diagnostics improvement

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
Co-authored-by: 派尼尔 <painier@openclaw.ai>
hanqizheng pushed a commit to hanqizheng/openclaw that referenced this pull request Mar 2, 2026
…rror (openclaw#29355)

* fix(browser): include Chrome stderr and sandbox hint in CDP startup error (openclaw#29312)

When Chrome fails to start and CDP times out, the error message previously
contained no diagnostic information, making it impossible to determine why
Chrome couldn't start (e.g. missing --no-sandbox in containers, GPU issues,
shared memory errors).

This change:
- Collects Chrome's stderr output and includes up to 2000 chars in the error
- On Linux, if noSandbox is not set, appends a hint to try browser.noSandbox: true

Closes openclaw#29312

* chore(browser): format chrome startup diagnostics

* fix(browser): detach stderr listener after Chrome starts to prevent memory leak

Named the anonymous listener so it can be removed via proc.stderr.off()
once CDP is confirmed reachable. Also clears the stderrChunks array on
success so the buffered data is eligible for GC.

Fixes the unbounded memory growth reported in code review: a long-lived
Chrome process emitting periodic warnings would keep appending to
stderrChunks indefinitely since the listener was never removed.

Addresses review comment from chatgpt-codex-connector on PR openclaw#29355.

* changelog: note cdp startup diagnostics improvement

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
Co-authored-by: 派尼尔 <painier@openclaw.ai>
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
…rror (openclaw#29355)

* fix(browser): include Chrome stderr and sandbox hint in CDP startup error (openclaw#29312)

When Chrome fails to start and CDP times out, the error message previously
contained no diagnostic information, making it impossible to determine why
Chrome couldn't start (e.g. missing --no-sandbox in containers, GPU issues,
shared memory errors).

This change:
- Collects Chrome's stderr output and includes up to 2000 chars in the error
- On Linux, if noSandbox is not set, appends a hint to try browser.noSandbox: true

Closes openclaw#29312

* chore(browser): format chrome startup diagnostics

* fix(browser): detach stderr listener after Chrome starts to prevent memory leak

Named the anonymous listener so it can be removed via proc.stderr.off()
once CDP is confirmed reachable. Also clears the stderrChunks array on
success so the buffered data is eligible for GC.

Fixes the unbounded memory growth reported in code review: a long-lived
Chrome process emitting periodic warnings would keep appending to
stderrChunks indefinitely since the listener was never removed.

Addresses review comment from chatgpt-codex-connector on PR openclaw#29355.

* changelog: note cdp startup diagnostics improvement

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
Co-authored-by: 派尼尔 <painier@openclaw.ai>
dawi369 pushed a commit to dawi369/davis that referenced this pull request Mar 3, 2026
…rror (openclaw#29355)

* fix(browser): include Chrome stderr and sandbox hint in CDP startup error (openclaw#29312)

When Chrome fails to start and CDP times out, the error message previously
contained no diagnostic information, making it impossible to determine why
Chrome couldn't start (e.g. missing --no-sandbox in containers, GPU issues,
shared memory errors).

This change:
- Collects Chrome's stderr output and includes up to 2000 chars in the error
- On Linux, if noSandbox is not set, appends a hint to try browser.noSandbox: true

Closes openclaw#29312

* chore(browser): format chrome startup diagnostics

* fix(browser): detach stderr listener after Chrome starts to prevent memory leak

Named the anonymous listener so it can be removed via proc.stderr.off()
once CDP is confirmed reachable. Also clears the stderrChunks array on
success so the buffered data is eligible for GC.

Fixes the unbounded memory growth reported in code review: a long-lived
Chrome process emitting periodic warnings would keep appending to
stderrChunks indefinitely since the listener was never removed.

Addresses review comment from chatgpt-codex-connector on PR openclaw#29355.

* changelog: note cdp startup diagnostics improvement

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
Co-authored-by: 派尼尔 <painier@openclaw.ai>
OWALabuy pushed a commit to kcinzgg/openclaw that referenced this pull request Mar 4, 2026
…rror (openclaw#29355)

* fix(browser): include Chrome stderr and sandbox hint in CDP startup error (openclaw#29312)

When Chrome fails to start and CDP times out, the error message previously
contained no diagnostic information, making it impossible to determine why
Chrome couldn't start (e.g. missing --no-sandbox in containers, GPU issues,
shared memory errors).

This change:
- Collects Chrome's stderr output and includes up to 2000 chars in the error
- On Linux, if noSandbox is not set, appends a hint to try browser.noSandbox: true

Closes openclaw#29312

* chore(browser): format chrome startup diagnostics

* fix(browser): detach stderr listener after Chrome starts to prevent memory leak

Named the anonymous listener so it can be removed via proc.stderr.off()
once CDP is confirmed reachable. Also clears the stderrChunks array on
success so the buffered data is eligible for GC.

Fixes the unbounded memory growth reported in code review: a long-lived
Chrome process emitting periodic warnings would keep appending to
stderrChunks indefinitely since the listener was never removed.

Addresses review comment from chatgpt-codex-connector on PR openclaw#29355.

* changelog: note cdp startup diagnostics improvement

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
Co-authored-by: 派尼尔 <painier@openclaw.ai>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…rror (openclaw#29355)

* fix(browser): include Chrome stderr and sandbox hint in CDP startup error (openclaw#29312)

When Chrome fails to start and CDP times out, the error message previously
contained no diagnostic information, making it impossible to determine why
Chrome couldn't start (e.g. missing --no-sandbox in containers, GPU issues,
shared memory errors).

This change:
- Collects Chrome's stderr output and includes up to 2000 chars in the error
- On Linux, if noSandbox is not set, appends a hint to try browser.noSandbox: true

Closes openclaw#29312

* chore(browser): format chrome startup diagnostics

* fix(browser): detach stderr listener after Chrome starts to prevent memory leak

Named the anonymous listener so it can be removed via proc.stderr.off()
once CDP is confirmed reachable. Also clears the stderrChunks array on
success so the buffered data is eligible for GC.

Fixes the unbounded memory growth reported in code review: a long-lived
Chrome process emitting periodic warnings would keep appending to
stderrChunks indefinitely since the listener was never removed.

Addresses review comment from chatgpt-codex-connector on PR openclaw#29355.

* changelog: note cdp startup diagnostics improvement

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
Co-authored-by: 派尼尔 <painier@openclaw.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Browser control service CDP timeout on Linux (port 18800)

2 participants