Repository navigation
fix: honor a Retry-After that fits inside a review wait's deadline - #130
Open
abdelrahman-ah1 wants to merge 3 commits into
Open
abdelrahman-ah1 wants to merge 3 commits into
abdelrahman-ah1 wants to merge 3 commits into
Conversation
The published SDK docs say a review wait stops early only when a 429 or 503 retry delay would reach or pass the remaining budget. The transport applied the one-minute cap that single reads use instead, so a Retry-After of 61 to 90 seconds inside a ten-minute wait ended the wait with the server's 503 refusal after one read. The cap now applies only to reads without a caller deadline. A wait passes its own deadline, so a Retry-After that fits inside it is waited out, and one that reaches the deadline still returns TIMED_OUT.
The new test pins the behavior from the previous commit: a 90-second Retry-After inside a ten-minute wait is slept out and the wait completes, the same hint inside a one-minute wait returns TIMED_OUT instead of throwing, and a single read still refuses a hint it cannot spend.
scripts/repro-retry-after.mjs starts a server that answers the first review read with 503 and Retry-After: 90, then a completed review. Run it after pnpm build: against the build before this branch it throws the 503 after one read, and against this branch it completes after two.
This branch has not been deployed
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.
What this changes
A review wait now honors a
Retry-Afterthat fits inside its own deadline, instead of ending with the server's refusal.Transport.requestappliedMAX_RETRY_SECONDS(60) to everyRetry-Afterheader, including the readswaitForReviewmakes with a deadline. A server that answered a review read with503andRetry-After: 90inside a ten-minute wait got no retry at all:retryDelayreturnedundefined, the read threw, andwaitForReviewrejected withProoflineError503 after a single read.The docs say a wait stops early only when the retry delay would reach or pass the deadline (https://proofline.sh/docs/sdks). The deadline check directly below the delay already covers that case and returns
TIMED_OUT, so the one-minute cap now applies only to reads without a caller deadline.Reproduction
repro-retry-after.mjsstarts a server that answers the first review read with503+Retry-After: 90and the second with a completed review, then callswaitForReviewwithtimeoutMs: 10 * 60_000. It compresses the retry sleep and records what the client asked to sleep for.threw ProoflineError 503: Proofline request failed with status 503 after 1 reads, slept []outcome COMPLETED after 2 reads, slept 90000Tests
tests/http.test.mjs: "a review wait honors a Retry-After longer than one read does" covers a 90-second hint inside a ten-minute wait (slept out, wait completes), the same hint inside a one-minute wait (returnsTIMED_OUTinstead of throwing), and a plaingetReview(still refuses a hint it cannot spend).node --test tests/*.test.mjs-> 110 pass, 0 fail, three consecutive runspnpm typecheck,pnpm lint,node generate.mjs --check,node check-claims.mjs-> cleanPython SDK
retry_delayinsdk-python/proofline/_transport.pycaps the header at 60 seconds the same way, sowait_for_reviewrejects with the 503 in the same situation. This PR does not touch it.