Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Risk of tight-spin until timeout when the WebSocket is closed/errored.
The refactor correctly stops treating a single empty batch as terminal, but it also drops the only signal the outer loop had for a dead stream.
read_lines_innerreturns an emptyVec<String>promptly (without consuming wall time) whenever the underlyingws_read.next()yieldsOk(None)orOk(Some(Message::Close(_)))(see lines 525), i.e. after the daemon disconnects. In that scenariowait_for_remote_json_rpc_responsewill now re-invokepollimmediately, every iteration returning instantly withvec![], burning a core until the caller'stimeoutelapses — and only then surfacingPyTimeoutErrorinstead of a prompt connection error.The previous code at least bailed out of the loop on the first empty batch, so a severed session failed fast. The new logic needs an equivalent "no more data will ever come" exit path.
Suggested shape: let the poller distinguish "waited and got nothing" from "stream is done", e.g. return
Option<Vec<String>>(None = terminal) or a small enum, and havewait_for_remote_json_rpc_responsebreak on the terminal variant:♻️ Sketch of a terminal-aware poll contract
…and have
read_lines_inner(or a thin wrapper used only bywrite_json_rpc) report theOk(None)/Closecase asNone. As a cheaper alternative, detect "poll returned faster thanremaining" and insert a boundedsleep/ break, but an explicit terminal signal is more robust.Also applies to: 542-557
🤖 Prompt for AI Agents