fix(oauth): prevent refresh manager deadloop on server-not-found errors [#310]#315
Merged
fix(oauth): prevent refresh manager deadloop on server-not-found errors [#310]#315
Conversation
…rs [#310] Fix three bugs causing infinite 0-delay retry loops when an OAuth server is removed from config or becomes unavailable: 1. Integer overflow in calculateBackoff: 1<<uint(retryCount) overflows at retryCount>=30, producing negative then zero durations. Cap the exponent at 25 and guard against non-positive results. 2. "server not found" errors classified as retryable: Add new terminal classification "failed_server_gone" for server-not-found and server-does-not-use-OAuth errors that stop retries immediately. 3. No maximum retry limit: Change DefaultMaxRetries from 0 (unlimited) to 50 as a circuit breaker. Also enforce MinRefreshInterval (5s) as minimum delay floor in rescheduleAfterDelay. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Deploying mcpproxy-docs with
|
| Latest commit: |
8aebb87
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a68e9f56.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-oauth-refresh-deadloop-3.mcpproxy-docs.pages.dev |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 22545972405 --repo smart-mcp-proxy/mcpproxy-go
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Fixes #310 — OAuth refresh manager enters infinite loop with 0-second delays when a server is removed from config, producing 23M+ retries and flooding logs.
Root cause: Three interconnected bugs in
refresh_manager.go:calculateBackoff:1 << uint(retryCount)overflowsint64at retryCount >= 30, producing negative then zero durationsDefaultMaxRetries = 0meant unlimited retries with no circuit breakerFixes applied:
MaxRetryBackoff= 5min)"failed_server_gone"for "server not found" and "server does not use OAuth" — stops retries immediatelyDefaultMaxRetriesfrom 0 to 50 as circuit breaker (~2+ hours with exponential backoff)MinRefreshInterval(5s) as minimum delay floor inrescheduleAfterDelayTest plan
TestRefreshManager_BackoffOverflowProtection— verifies backoff is positive and capped at retryCount 30, 63, 64, 100, 1000, and 23,158,728TestRefreshManager_ServerNotFoundIsTerminal— verifies immediate stop on server-not-foundTestRefreshManager_MaxRetryLimit— verifies circuit breaker stops retries at limitTestDefaultMaxRetries_IsNonZero— guards against regression to unlimitedTestRefreshManager_MinimumDelayEnforced— verifies 0/negative delays clamped to 5sTestClassifyRefreshErrorwith server-gone error cases-race🤖 Generated with Claude Code