Repository navigation
Conversation
Token refresh failures were all reported as "authorization has expired, re-authorize", even for proxy timeouts or provider 5xx, and a dead grant kept workers hitting the token endpoint forever. - tokenRequest throws OAuthTokenError with the OAuth error code and status - invalid_grant / interaction_required / consent_required ask the user to re-authorize and mark the error reauthRequired; invalid_client / unauthorized_client point at the OAuth app settings; network errors, timeouts and 5xx say the refresh will be retried - Graph and IMAP workers stop polling / reconnecting on a reauthRequired error; re-authorization already restarts the worker via syncEngine.restartAccount - Graph / IMAP / SMTP error describers keep the refresh error message - Re-authorization clears the cached token and in-flight refresh, and a refresh that races it never writes the old grant's tokens back - Tests for the error classification, worker stop/retry and cache reset Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Every OAuth token refresh failure was reported as "authorization has expired, re-authorize", including proxy timeouts and provider 5xx errors. Once a refresh token was dead for real, the Graph worker kept calling the token endpoint every minute, and the IMAP worker kept reconnecting with backoff, with no end.
tokenRequestnow throwsOAuthTokenError, which keeps the OAutherrorcode and the HTTP status.refreshAccessTokensorts failures into three groups:invalid_grant/interaction_required/consent_required: asks the user to re-authorize the mailbox and marks the errorreauthRequired.invalid_client/unauthorized_client: tells the user to check the Client ID and secret in the OAuth app settings.reauthRequirederror. Re-authorizing already restarts the worker (syncEngine.restartAccountinapi/oauth.ts). Other errors are retried the same way as before.Test plan
npm run typechecknpm test: 195/195 pass, including the newtest/mailbox-oauth-refresh.test.ts(error classification and messages, workers stopping vs retrying, token cache reset after re-authorization)🤖 Generated with Claude Code