fix: OAuth token refresh retry and error handling for idle timeout#133
Merged
anandgupta42 merged 1 commit intomainfrom Mar 14, 2026
Merged
fix: OAuth token refresh retry and error handling for idle timeout#133anandgupta42 merged 1 commit intomainfrom
anandgupta42 merged 1 commit intomainfrom
Conversation
) After 20+ minutes idle, OAuth tokens expire and subsequent prompts show unhelpful "Error" with no context or retry. This commit fixes the issue across Anthropic and Codex OAuth plugins: - Add 3-attempt retry with backoff for token refresh (network/5xx only) - Fail fast on 4xx auth errors (permanent failures like revoked tokens) - Add 30-second proactive refresh buffer to prevent mid-request expiry - Update `currentAuth.expires` after successful refresh - Classify token refresh failures as `ProviderAuthError` for actionable error messages with recovery instructions - Make auth errors retryable at session level with user-facing guidance - Improve generic `Error` display (no more bare "Error" in TUI) Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
anandgupta42
added a commit
that referenced
this pull request
Mar 17, 2026
) (#133) After 20+ minutes idle, OAuth tokens expire and subsequent prompts show unhelpful "Error" with no context or retry. This commit fixes the issue across Anthropic and Codex OAuth plugins: - Add 3-attempt retry with backoff for token refresh (network/5xx only) - Fail fast on 4xx auth errors (permanent failures like revoked tokens) - Add 30-second proactive refresh buffer to prevent mid-request expiry - Update `currentAuth.expires` after successful refresh - Classify token refresh failures as `ProviderAuthError` for actionable error messages with recovery instructions - Make auth errors retryable at session level with user-facing guidance - Improve generic `Error` display (no more bare "Error" in TUI) Co-authored-by: Claude Opus 4.6 <[email protected]>
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 does this PR do?
Fixes the issue where leaving altimate-code idle for 20+ minutes causes every subsequent prompt to show just "Error" with no context or recovery path. The root cause is OAuth tokens expiring after idle, and the token refresh throwing a plain
Errorwith no retry logic.Changes:
anthropic.ts/codex.ts: Add 3-attempt retry with exponential backoff for token refresh, fail-fast on 4xx (permanent auth failures), 30s proactive refresh buffer before expiry, fixcurrentAuth.expiresnot being updated after successful refreshmessage-v2.ts: Classify OAuth token refresh failures asProviderAuthErrorinstead ofUnknownError, improve generic Error display (no more bare "Error" in TUI)retry.ts: Make auth errors retryable at session level with actionable user message including recovery instructionsretry.test.ts: Add 8 new tests covering auth error retry, token refresh failure classification, and generic error handlingType of change
Issue for this PR
Closes #118
How did you verify your code works?
bun test test/session/retry.test.ts)bun test test/session/message-v2.test.ts)bunx tsc --noEmit)Checklist