Skip to content

fix(browser): prevent stdio buffer blocking in Docker environments#27899

Open
stephenschoettler wants to merge 2 commits intoopenclaw:mainfrom
stephenschoettler:fix/docker-browser-stdio
Open

fix(browser): prevent stdio buffer blocking in Docker environments#27899
stephenschoettler wants to merge 2 commits intoopenclaw:mainfrom
stephenschoettler:fix/docker-browser-stdio

Conversation

@stephenschoettler
Copy link

Fixes browser automation failures in Docker by changing Chrome spawn configuration from stdio: "pipe" to stdio: ["ignore", "ignore", "ignore"].

Problem: When using stdio: "pipe", Chrome's stdout/stderr buffers fill up (~64KB limit) and block the process, preventing CDP from becoming reachable within the timeout window.

Solution: Discard Chrome's output instead of piping it. The codebase doesn't consume Chrome's stdout/stderr anyway, so there's no functional loss.

Result: CDP becomes reachable within ~500ms of Chrome startup in Docker.

Tested manually in Docker with Playwright Chromium on Debian 12.

Prevents crash when totals is undefined in byModel/byProvider/byAgent
sort comparators. Fixes 'Cannot read properties of undefined (reading
totalTokens)' crash that causes context overflow in active sessions.
@openclaw-barnacle openclaw-barnacle bot added gateway Gateway runtime size: XS labels Feb 26, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

This PR contains two separate bug fixes:

  1. Browser stdio fix (chrome.ts): Changed Chrome spawn configuration from stdio: "pipe" to stdio: ["ignore", "ignore", "ignore"] to prevent buffer blocking in Docker environments. The codebase doesn't consume Chrome's stdout/stderr streams anywhere, so discarding them is safe and resolves the CDP timeout issue.

  2. Null guard fix (usage.ts, session-cost-usage.ts): Added optional chaining and nullish coalescing to usage sort comparators to prevent crashes when totals is undefined. The fix prevents "Cannot read properties of undefined" errors in production.

Note: The PR title only mentions the browser fix, but includes the unrelated usage fix as well. According to the project's guidelines (CLAUDE.md), unrelated changes should typically be in separate PRs. Both fixes are valid, but bundling them may make the PR history harder to track.

Confidence Score: 4/5

  • This PR is safe to merge with low risk
  • Both fixes address real bugs and are technically correct. The stdio change is well-justified and doesn't break any existing functionality (verified that Chrome stdout/stderr are unused). The null guards are defensive programming that prevent actual crashes. Score is 4 instead of 5 due to: (1) bundling two unrelated fixes in one PR, which goes against project guidelines, and (2) missing test coverage for the fixes.
  • No files require special attention

Last reviewed commit: 200f8c0

@openclaw-barnacle
Copy link

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

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Mar 4, 2026
@stephenschoettler
Copy link
Author

Note: the install-smoke failure blocking PR #31192 is the same src/browser/chrome.ts stdin type mismatch that this PR fixes. Merging this PR (#27899) should unblock #31192's CI as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant