fix: coalesce auth-triggered GetProfile checks in ProfileStatusMonitor - #2872
Draft
laileni-aws wants to merge 1 commit into
Draft
fix: coalesce auth-triggered GetProfile checks in ProfileStatusMonitor#2872laileni-aws wants to merge 1 commit into
laileni-aws wants to merge 1 commit into
Conversation
Every auth success event ran an independent MCP configuration check, and each check issued its own GetProfile request. Bursts of token refreshes or repeated profile configuration updates therefore turned into bursts of GetProfile calls, made worse during backend errors because each check also retried. Share a single in-flight check between concurrent callers, and skip auth-triggered checks for the same profile within a one-minute cooldown. Explicit initial and periodic checks are unchanged, and a profile change still triggers an immediate check.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Problem
ProfileStatusMonitorre-checks the profile's MCP configuration (aGetProfilerequest) every time an auth success event fires. Auth success is emitted on everyaws/updateConfigurationthat carries aprofileArn— including when the profile did not change — and on credential updates, so a client that refreshes its token or re-pushes its configuration several times in a short window causes the language server to issue oneGetProfilerequest per event.Two things make this worse:
retryWithBackoff, so during a backend error every event costs up to two requests.The net effect is that a single IDE can generate dozens of
GetProfilecalls per minute for the same profile, and the rate goes up when the service is returning 5xx.Solution
onAuthSuccess(), which skips the check when the same profile ARN was already checked withinAUTH_EVENT_MIN_INTERVAL_MS(60s). The timestamp is recorded before the request so failed checks are rate-limited too. A different profile ARN still triggers an immediate check.isMcpEnabled()return the in-flight promise when a check is already running, so concurrent callers (auth event +checkInitialState(), or repeated events) share oneGetProfilerequest.checkInitialState()and the 24-hour periodic check keep their existing behaviour; the cooldown only applies to event-triggered checks.void this.isMcpEnabled()could surface as an unhandled rejection; the error is already logged inside the check).Adds unit tests covering: concurrent checks share one request, sequential checks still run, cooldown suppresses repeats for the same profile and lifts after the interval, profile change bypasses the cooldown, and cooldown applies after a failed (5xx) check.
Testing:
ts-mocha src/language-server/agenticChat/tools/mcp/profileStatusMonitor.test.ts— all new tests pass; the pre-existingstatic lastMcpStatetest that depends on a cached state file on disk is unaffected by this change. Prettier and eslint pass on the changed files.License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.