fix: retry refresh only on transient failures, not on de-auth - #245
Open
major0 wants to merge 1 commit into
Open
fix: retry refresh only on transient failures, not on de-auth#245major0 wants to merge 1 commit into
major0 wants to merge 1 commit into
Conversation
major0
force-pushed
the
fix/refresh-retry-skip-deauth
branch
from
July 31, 2026 13:44
50ce7e9 to
8e5014d
Compare
retryRefreshFailed (added in 0f1b604, "feat(BRIDGE-586): add retry-condition for refresh failed") retries a failed /auth/v4/refresh when the response is 400 or 422, and does not retry 5xx. This appears inverted: - 400 and 422 on /auth/v4/refresh are the permanent de-auth signal. authRefresh in client.go treats those exact status codes as de-auth (running the de-auth handlers). Retrying them cannot succeed with the same dead refresh token; with the default retryCount of 3 it issues four refresh attempts, hammering the auth endpoint and delaying the de-auth signal to callers. - 5xx is a transient server error that is the normal candidate for a retry, yet it is currently excluded. Narrow the condition to retry only genuinely transient failures: no response reached the client (network error / timeout) or a 5xx server error. 400/422 now fall through immediately so the de-auth path fires on the first response. The accompanying test's expectations are corrected to match (400/422 -> no retry, 500 -> retry). Note: BRIDGE-586 is an internal ticket with no public rationale, so this assumes the original status set was inverted. If there is a specific transient 400/422 case this was meant to paper over (e.g. a refresh-token rotation race), please advise and we can scope the retry to that case instead. Ref: ProtonMail/go-proton-api@0f1b604
major0
force-pushed
the
fix/refresh-retry-skip-deauth
branch
from
August 11, 2026 15:17
8e5014d to
25c4da4
Compare
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.
retryRefreshFailed (added in 0f1b604, "feat(BRIDGE-586): add retry-condition for refresh failed") retries a failed /auth/v4/refresh when the response is 400 or 422, and does not retry 5xx. This appears inverted:
Narrow the condition to retry only genuinely transient failures: no response reached the client (network error / timeout) or a 5xx server error. 400/422 now fall through immediately so the de-auth path fires on the first response. The accompanying test's expectations are corrected to match (400/422 -> no retry, 500 -> retry).
Note: BRIDGE-586 broke unit tests in https://github.com/major0/proton-utils.git due to the seemingly inverted retry logic.
Refs: