fix: add timeouts to remote resolution in status read path#107
Open
lehuan5062 wants to merge 2 commits into
Open
fix: add timeouts to remote resolution in status read path#107lehuan5062 wants to merge 2 commits into
lehuan5062 wants to merge 2 commits into
Conversation
Add 5-second connect timeouts to gRPC and QUIC transports, and time-box the remote branch resolution in status() to 3 seconds. When the configured remote is unreachable, status calls now degrade gracefully instead of stalling for the full idle timeout (~30s for QUIC, 10s+ for retries). Critical fixes: 1. Time-box the entire remote resolution operation (both repository.remote() and branch::load_remote()), not just the fast path. This ensures the 3-second deadline covers the actual RPC calls that can hang indefinitely, even when the remote connection is already warm. 2. Fix available flag semantics: distinguish between "remote not reachable" (available=false) and "remote reachable but query failed" (available=true). A server that responds with a permission error or other non-branch-not-found error is still reachable and should not be reported as unavailable to users. Changes: - lore-transport: gRPC endpoint gets connect_timeout for initial connection - lore-revision: extract resolve_remote_latest() helper that returns (latest, authorized, available) where available reflects connection success rather than query success; eliminate double remote() call on event emission - tests: replace overfitted tautological test with two real unit tests Signed-off-by: Huân Lê-Vương <65440815+lehuan5062@users.noreply.github.com>
31b1539 to
e5c3112
Compare
clippy::doc_markdown (denied via -D warnings in the pre-commit hook) flags bare type-name references in doc comments. CI caught this; local clippy runs missed it because they weren't re-run after this doc comment was added in a later revision of the same change. Signed-off-by: Huân Lê-Vương <65440815+lehuan5062@users.noreply.github.com>
ragnarula
reviewed
Jul 13, 2026
ragnarula
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the fix, but I'm not quite sure I follow the problem or the reasoning. We're adding timeouts to the connect calls, but then not waiting long enough to let them resolve.
Is the issue that loading the remote branch is taking too long? Sometimes that is just a slower operation, I don't think timing out is a good fix for that, I'd rather we thought about how to accelerate lookup.
| ) -> (Option<Hash>, bool, bool) { | ||
| let remote = match repository.remote().await { | ||
| Ok(r) => r, | ||
| Err(_) => return (None, false, false), |
Collaborator
There was a problem hiding this comment.
What other errors could this produce that we're potentially throwing away here?
| match branch::load_remote(remote, repository.id, branch_id).await { | ||
| Ok(status) => (Some(status.latest), true, true), | ||
| Err(err) if err.is_branch_not_found() => (None, true, true), | ||
| Err(_) => (None, false, true), |
| Ok((directories, files)) | ||
| } | ||
|
|
||
| const REMOTE_RESOLVE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(3); |
Collaborator
There was a problem hiding this comment.
Why make this shorter than the connect/handshake timeouts?
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add 5-second connect timeouts to gRPC and QUIC transports, and time-box the remote branch resolution in status() to 3 seconds. When the configured remote is unreachable, status calls now degrade gracefully instead of stalling for the full idle timeout (~30s for QUIC, 10s+ for retries).
Critical fixes:
Time-box the entire remote resolution operation (both repository.remote() and branch::load_remote()), not just the fast path. This ensures the 3-second deadline covers the actual RPC calls that can hang indefinitely, even when the remote connection is already warm.
Fix available flag semantics: distinguish between "remote not reachable" (available=false) and "remote reachable but query failed" (available=true). A server that responds with a permission error or other non-branch-not-found error is still reachable and should not be reported as unavailable to users.
Changes: