Repository navigation
feat(client)!: retry only idempotent methods by default and make retries safer - #14
Merged
Merged
Conversation
…ies safer RetryPolicy now retries only GET, HEAD, OPTIONS, TRACE, PUT and DELETE (RFC 9110 section 9.2.2) unless retryableMethods says otherwise. The new constructor argument is appended last, so existing positional calls keep working. Retry-After is capped at maxDelay, and a request whose body is not seekable is sent once: a retry used to send an empty body because the first attempt had already consumed the stream.
Reading the method or body of a request while deciding whether it may be replayed could leak a raw exception when a policy was attached; such a request is now sent once and fails as a RequestException, as without a policy. Also document that maxDelay caps Retry-After in the RetryPolicy docblocks, correct the CHANGELOG migration recipe and the README comment.
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
RetryPolicyretries only idempotent methods by default (RFC 9110 section 9.2.2: GET, HEAD, OPTIONS, TRACE, PUT, DELETE). POST and PATCH are sent once unless listed in the new, last constructor argumentretryableMethods. Breaking.Retry-Afteris capped atmaxDelay(a server could previously make the client wait an hour).Client-Retry,Client-Configuration, README) andCHANGELOG.md[Unreleased]updated.Test plan
composer validate --strictvendor/bin/php-cs-fixer fix --dry-run --diffvendor/bin/phpstan analyse --memory-limit=512Mvendor/bin/phpunit(new unit tests plus end-to-end tests against the fixture server)wiki-sync.sh --checkrc=0