fix(cow-ext): map reqwest timeout and 429 to Fault::Timeout / RateLimited#357
Closed
lgahdl wants to merge 2 commits into
Closed
fix(cow-ext): map reqwest timeout and 429 to Fault::Timeout / RateLimited#357lgahdl wants to merge 2 commits into
lgahdl wants to merge 2 commits into
Conversation
…ited ext_cow.rs projected every reqwest::Error onto the blanket Fault::Unavailable and every non-2xx status (including 429) onto the generic Http case, hiding backpressure and slow-request signals a caller's retry logic could otherwise act on precisely. Mirrors the chain-host's transport_fault classification (crates/nexum-runtime/src/ host/error.rs): a 429 now becomes Fault::RateLimited, and a genuine reqwest timeout becomes Fault::Timeout. retry_after_ms stays None - extracting it from the response would need a Retry-After header threaded through CowApiError::HttpError, tracked separately by nullislabs#269. Fixes nullislabs#287.
Relying on a non-routable IP (10.255.255.1) to force a reqwest timeout is CI-runner-dependent: some network stacks fail the connect attempt instantly with "no route to host" rather than hanging until the deadline, which is a different reqwest error kind than a timeout. Accept the connection but never respond instead, so the client's deadline fires on a genuine read-timeout regardless of environment.
Collaborator
Author
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.
Summary
Fixes #287.
ext_cow.rs'scow_error_to_witmapped everyreqwest::Erroronto the blanketFault::Unavailable, and every non-2xx orderbook status (including 429) onto the genericHttpcase — hiding two signals a caller's retry/backoff logic could otherwise act on precisely.CowApiError::HttpError { status: 429, .. }) now becomesFault::RateLimited(RateLimit { retry_after_ms: None })instead ofHttp(HttpFailure).reqwesttimeout (CowApiError::Network(e)wheree.is_timeout()) now becomesFault::Timeoutinstead ofFault::Unavailable.This mirrors the chain-host's existing
transport_faultclassification (crates/nexum-runtime/src/host/error.rs), which already does the same 429→RateLimited/ timeout→Timeoutsplit for the chain-RPC side (#269's title calls this pattern out for that side).retry_after_msstaysNone— extracting a real value would require threading the response'sRetry-Afterheader throughCowApiError::HttpError, which is a distinct, currently-blocked follow-up (#269 covers populating it generally).Test plan
cargo test -p shepherd-cow-host ext_cow::— addedbackend_http_429_projects_to_rate_limited_faultandbackend_network_timeout_projects_to_timeout_fault(the latter drives a realreqwest::Clientagainst a non-routable address with a 1ms deadline to get a genuine timeout error), both pass alongside the 4 existing testscargo clippy -p shepherd-cow-host --all-targets --all-features --locked -- -D warningscleancargo fmt -p shepherd-cow-host -- --checkclean