Skip to content

fix: add timeouts to remote resolution in status read path#107

Open
lehuan5062 wants to merge 2 commits into
EpicGames:mainfrom
lehuan5062:fix/remote-resolution-timeout
Open

fix: add timeouts to remote resolution in status read path#107
lehuan5062 wants to merge 2 commits into
EpicGames:mainfrom
lehuan5062:fix/remote-resolution-timeout

Conversation

@lehuan5062

Copy link
Copy Markdown
Member

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

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>
@lehuan5062 lehuan5062 force-pushed the fix/remote-resolution-timeout branch from 31b1539 to e5c3112 Compare July 11, 2026 14:24
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 ragnarula left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Ok((directories, files))
}

const REMOTE_RESOLVE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(3);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make this shorter than the connect/handshake timeouts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants