File tree Expand file tree Collapse file tree
engine/packages/guard-core/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -226,7 +226,9 @@ pub(crate) fn should_retry_request(res: &Result<Response<ResponseBody>>) -> bool
226226 }
227227}
228228
229- // Determine if a response should trigger a retry: 503 + x-rivet-error
229+ // Determine if a response should trigger a retry. Guard-specific actor startup
230+ // failures, including guard.actor_ready_timeout, are signaled as 503 with
231+ // x-rivet-error and should be retried against a freshly resolved target.
230232pub ( crate ) fn should_retry_request_inner ( status : StatusCode , headers : & hyper:: HeaderMap ) -> bool {
231233 status == StatusCode :: SERVICE_UNAVAILABLE && headers. contains_key ( X_RIVET_ERROR )
232234}
@@ -294,3 +296,7 @@ pub(crate) fn to_hyper_close(frame: Option<CloseFrame>) -> hyper_tungstenite::tu
294296 ) )
295297 }
296298}
299+
300+ #[ cfg( test) ]
301+ #[ path = "utils/tests.rs" ]
302+ mod tests;
Original file line number Diff line number Diff line change 1+ use hyper:: header:: HeaderValue ;
2+
3+ use super :: * ;
4+
5+ #[ test]
6+ fn retries_guard_actor_ready_timeout_response ( ) {
7+ let mut headers = hyper:: HeaderMap :: new ( ) ;
8+ headers. insert (
9+ X_RIVET_ERROR ,
10+ HeaderValue :: from_static ( "guard.actor_ready_timeout" ) ,
11+ ) ;
12+
13+ assert ! ( should_retry_request_inner(
14+ StatusCode :: SERVICE_UNAVAILABLE ,
15+ & headers,
16+ ) ) ;
17+ }
18+
19+ #[ test]
20+ fn skips_service_unavailable_without_rivet_error_header ( ) {
21+ let headers = hyper:: HeaderMap :: new ( ) ;
22+
23+ assert ! ( !should_retry_request_inner(
24+ StatusCode :: SERVICE_UNAVAILABLE ,
25+ & headers,
26+ ) ) ;
27+ }
28+
29+ #[ test]
30+ fn skips_non_service_unavailable_with_rivet_error_header ( ) {
31+ let mut headers = hyper:: HeaderMap :: new ( ) ;
32+ headers. insert ( X_RIVET_ERROR , HeaderValue :: from_static ( "guard.no_route" ) ) ;
33+
34+ assert ! ( !should_retry_request_inner( StatusCode :: NOT_FOUND , & headers) ) ;
35+ }
You can’t perform that action at this time.
0 commit comments