fix: extend daemon proxy read timeout - #1885
Conversation
The MCP stdio proxy forwarded tool calls to the daemon over a Unix socket with a 10-second read timeout. Slow get_window_state calls could exceed that transport budget before the tool-level timeout fired, causing macOS EAGAIN/os error 35 to surface as a daemon transport failure.\n\nThis change gives the daemon proxy a 60-second read timeout, keeps the existing short write timeout, and normalizes WouldBlock/TimedOut into a clear daemon timeout error. It also adds focused tests for response-line handling and timeout mapping.\n\nBefore this change, a delayed daemon response reproduced the issue by failing around 10 seconds. After this change, a 12-second delayed MCP proxy call succeeds while still bounding truly stuck daemon reads.
|
@buiilding is attempting to deploy a commit to the Cua Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
closed as superseded by #1997 |
Summary
Fixes #1864.
This PR fixes the MCP -> daemon proxy timeout described in the issue. It does not make
get_window_statesmaller or bypass AX traversal; it makes the daemon transport wait long enough for legitimate tool execution and return a clearer transport timeout if the daemon still does not respond.Issue Behavior Addressed
The issue reports that this path can fail:
The same
get_window_stateoperation can look healthy throughcua-driver call, while the MCP proxy path fails with:The root cause fixed here is the proxy client read timeout:
send_requestused a hardcoded 10-second socket read timeout. Slow but valid daemon calls, especiallyget_window_state, could exceed that transport timeout before the tool returned its own result or timeout. On macOS, that timed-out socket read appears asWouldBlock/EAGAIN/ os error 35.What Changed
WouldBlock/TimedOutwhile reading the daemon response into a clear error:The 60-second transport budget is intentionally above the macOS
get_window_stateAX walk timeout of 30 seconds, leaving room for screenshot capture, resizing/encoding orscreenshot_out_file, and JSON response serialization.This PR intentionally does not blindly retry on
EAGAIN. In this code path,EAGAINis the socket read timeout firing, not a transient readiness event from a nonblocking socket loop. Retrying would hide the timeout policy instead of fixing the proxy deadline.Relation To The Issue's Upstream Questions
Resolved by this PR:
os error 35/EAGAINin the MCP -> daemon proxy no longer leaks as the primary failure for slow-but-valid daemon responses below the transport budget.get_window_stateAX timeout.EAGAIN.Not changed by this PR and still follow-up scope:
screenshot_out_fileshould be the recommended long-term payload-size strategy.window_idfor multi-window disambiguation.screenshottool is intentionally replaced byget_window_state(capture_mode=vision).screenshot_out_fileremains useful as an optional payload-size mitigation, but it is not the primary fix for this bug. The transport timeout/backpressure behavior is the bug addressed here.Validation
cargo test -p cua-driver daemon_response_read_testsgit diff --checkinstall-local.shrebuild and CuaDriver daemon restartget_window_statefor 12 seconds; the call succeeds instead of failing at the old ~10-second transport timeout