Skip to content

fix(browser): prevent open hangs and reduce startup overhead - #964

Merged
getappz merged 4 commits into
masterfrom
task/773-browser-open-hangs
Oct 26, 2026
Merged

getappz merged 4 commits into
masterfrom
task/773-browser-open-hangs

Conversation

@getappz

@getappz getappz commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Browser commands could finish navigating yet hang indefinitely because the persistent daemon and Chrome retained inherited output-pipe handles. Return when the command exits, drain pending output within the existing memory cap, and prevent the caller's original Windows stdio from leaking into redirected children.

Reuse the existing pipe-readiness checks for CLI and MCP calls. On Windows, preserve normal PATH priority and use the mise shim when it comes first, so cached install paths cannot override the project's selected version. Add regression coverage and a repeatable startup benchmark.

Pass stdin policy explicitly at the caller: the CLI inherits input for piped scripts such as eval -- --stdin, while both MCP paths and the benchmark use null input. Scripts stay on stdin, including those larger than Windows' command-line limit.

Validation:

  • mbx test -p flare-browser -p flare-process -- --test-threads=1: 21 passed; 7 subprocess fixtures intentionally ignored.
  • Red/green regressions for Windows shim priority and piped CLI input. Real-pipe coverage verifies null-input isolation and a script larger than 64 KiB.
  • mbx build --bin agentflare passed. Rebuilt Windows debug CLI returned 2 for piped 1+1 and 65536 for a piped 64 KiB string-length script in an isolated browser session.
  • cargo fmt --all -- --check, git diff --check, and independent review passed.

The original hang fix was smoke-tested and benchmarked with a Windows debug CLI. Startup timings have not been rerun after restoring shim priority; the previously reported shortcut timings do not describe the final version-selection path.

Linux/macOS, first-use installation downloads, and the full workspace suite were not run locally.


Opened by codex on i-flare-c997d745ae66 (flared:c997d745ae66) for item #773 via agentflare.

Summary by CodeRabbit

  • Bug Fixes
    • Improved browser process output handling and shutdown, reducing the chance of hangs when child processes keep output streams open.
    • Improved isolation of browser processes by preventing them from inheriting standard input and output handles.
  • Developer Tools
    • Added a benchmark example that measures cold and warm browser opens, snapshots, and URL reads, reporting elapsed time for each operation.

Agentflare-Branch: task/773-browser-open-hangs
Agentflare-Item: 773
Agentflare-Session: d4fb427d-cddf-4f95-946e-ab30a8a4660c
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 64 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1ea7f5b and cb5e804.

Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 8
  • crates/flare-browser/examples/bench_open.rs
  • crates/flare-browser/src/lib.rs
  • crates/flare-process/Cargo.toml
  • crates/flare-process/src/lib.rs
  • crates/flare-process/src/pipe.rs
  • src/agent_launch.rs
  • src/cli/browser.rs
  • src/mcp_server/browser.rs

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 28b0694 and 1ea7f5b.

Files selected for processing: 1
  • crates/flare-browser/src/lib.rs

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Walkthrough

The change adds cross-platform pipe-readiness and standard-handle inheritance helpers. Browser subprocess handling now drains bounded output while waiting for child exit. It also adds an example that benchmarks browser operations.

Changes: Browser process handling

Layer / File(s) Summary
Shared process and pipe helpers
crates/flare-process/Cargo.toml, crates/flare-process/src/lib.rs, crates/flare-process/src/pipe.rs, src/agent_launch.rs
The process crate adds platform-specific pipe-readiness helpers and a standard-handle inheritance helper. Agent launch imports the shared output-readiness helper.
Bounded subprocess output handling
crates/flare-browser/src/lib.rs
run_blocking prevents standard-handle inheritance, starts children with null stdin and piped output, and reads both output streams while waiting for child exit. Tests cover inherited pipes, output limits, and redacted failure reporting.

Browser open benchmark

Layer / File(s) Summary
Backend selection and benchmark run
crates/flare-browser/examples/bench_open.rs
The example selects a backend and runs five timed samples each for cold opens, warm opens, snapshots, and URL reads. It checks non-snapshot output and closes the session.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~30 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant BrowserCaller
  participant run_blocking
  participant prevent_stdio_inheritance
  participant ChildProcess
  participant StdoutReader
  participant StderrReader
  BrowserCaller->>run_blocking: start command
  run_blocking->>prevent_stdio_inheritance: clear standard-handle inheritance
  run_blocking->>ChildProcess: spawn with null stdin and piped output
  run_blocking->>StdoutReader: drain available stdout bytes
  run_blocking->>StderrReader: drain available stderr bytes
  ChildProcess-->>run_blocking: exit
  run_blocking->>StdoutReader: signal bounded post-exit drain
  run_blocking->>StderrReader: signal bounded post-exit drain
Loading
Merge Risk: Minimal · up to 1ea7f

The change fixes browser commands hanging on inherited output pipes. No merge-blocking issue remains in the reviewed changes. A possible Windows shim-selection limitation existed before this PR and is not made worse by it.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 31.58% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the browser fix and the startup overhead reduction, and it matches the summarized changes: non-hanging run_blocking with bounded drain, stdio inheritance prevention, and pipe-readiness…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description clearly explains the browser hang fix, Windows process and PATH behavior, caller stdin policy, regression coverage, benchmark status, and validation results. It does not use the templa…
Full details: Title check

Explanation

The title names the browser fix and the startup overhead reduction, and it matches the summarized changes: non-hanging run_blocking with bounded drain, stdio inheritance prevention, and pipe-readiness reuse. The 'reduce startup overhead' part is partly supported by the benchmark and the shim-priority change, but the description says the final startup timings were not rerun, so that half is less certain. The title is specific and follows the conventional-commit form, and it is not misleading.

Full details: Description check

Explanation

The description clearly explains the browser hang fix, Windows process and PATH behavior, caller stdin policy, regression coverage, benchmark status, and validation results. It does not use the template headings or checkbox format, and it omits an explicit Notes for reviewers section, but it includes the required testing details, risk limitations, and compatibility context.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@getappz
getappz marked this pull request as ready for review October 25, 2026 06:49
Agentflare-Branch: task/773-browser-open-hangs
Agentflare-Item: 773
Agentflare-Session: d4fb427d-cddf-4f95-946e-ab30a8a4660c
Agentflare-Branch: task/773-browser-open-hangs
Agentflare-Item: 773
Agentflare-Session: 5c89e410-2f92-4ef3-ad03-44c57dce1a55
@getappz

getappz commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@getappz

getappz commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@getappz
getappz merged commit f761b30 into master Oct 26, 2026
17 checks passed
@getappz
getappz deleted the task/773-browser-open-hangs branch October 26, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant