Skip to content

Commit 918952a

Browse files
committed
Bound a single contract-preview status attempt via AttemptTimeoutLayer
Mirrors WHOAMI_ATTEMPT_TIMEOUT: an inner per-attempt timeout layered under PollRetryPolicy's overall poll budget, so one hung status check can't consume checks_timeout_seconds in a single attempt. A timed-out attempt maps to `false` (not finished) rather than an error, so PollRetryPolicy just polls again on the normal schedule.
1 parent 504993a commit 918952a

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • crates/rover-client/src/operations/contract/preview

crates/rover-client/src/operations/contract/preview/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ mod types;
33

44
use std::time::Duration;
55

6-
use rover_tower::poll_retry::PollRetryPolicy;
6+
use rover_tower::{attempt_timeout::AttemptTimeoutLayer, poll_retry::PollRetryPolicy};
77
pub use service::{ContractPreviewResult, ContractPreviewStart};
88
use tower::{Service, ServiceBuilder, ServiceExt};
99
pub use types::*;
1010

1111
use crate::{blocking::StudioClient, RoverClientError};
1212

13+
/// Bounds a single status-check attempt, independent of the overall poll
14+
/// budget (`checks_timeout_seconds`) -- mirrors `WHOAMI_ATTEMPT_TIMEOUT` in
15+
/// `command::auth::whoami`: reusing the overall budget here would let one
16+
/// hung attempt consume the whole thing, leaving no room to poll again.
17+
const CONTRACT_PREVIEW_STATUS_ATTEMPT_TIMEOUT: Duration = Duration::from_secs(10);
18+
1319
/// Start an async contract preview job, returning its (pending) status
1420
/// immediately.
1521
pub async fn start(
@@ -58,6 +64,10 @@ pub async fn poll(
5864
}
5965
},
6066
))
67+
.layer(AttemptTimeoutLayer::new(
68+
CONTRACT_PREVIEW_STATUS_ATTEMPT_TIMEOUT,
69+
|| false,
70+
))
6171
.service(service::ContractPreviewStatus::new(
6272
client
6373
.studio_graphql_service()

0 commit comments

Comments
 (0)