You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AI code review — automated review for reference, author can ignore or act on any point.
Correct and minimal fix. I traced the timer lifecycle: the timeout is armed per attempt (connection.ts:67), cleared on server.connected (:82–85), and again in the finally block (:109), so there's no leak and a successful slow handshake is unaffected afterwards. Retrying with the existing 1s reconnectDelay still works because the timeout only bounds "TCP open but no server.connected", not fast network-refused failures.
Two things to consider:
The new bound also applies to reconnect attempts.connectTimeout gates every attempt in runStream, not just the initial handshake. When a server hangs (accepts TCP but never sends) mid-session, the status now sits in connecting/reconnecting for up to ~31s per attempt instead of ~3s before the first retry. That's the right trade-off for slow links, but worth confirming the UI communicates that state well over 30 seconds — users may assume the app is frozen rather than connecting.
Consider making it tunable.ClientConnectionOptions already carries knobs like flushInterval. Exposing connectTimeoutMs there (defaulting to 30_000) would let desktop/remote-SSH deployments tune it without another code change — this is the second latency-related tweak to this file, suggesting the value is environment-dependent.
Minor: a one-line comment on the constant explaining the rationale ("high-latency / remote backends can exceed 2s before server.connected") would prevent a future reader from "tightening" it back.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Summary
/api/eventbeforeserver.connectedarrivesTesting
bun typecheck(packages/client)bun typecheck(packages/app)bun test(packages/client): 61 passed; one unrelated generated-client surface assertion fails becausequestionis absent