fix(kiro): prevent expired token refresh stalls - #681
Open
HanqingAWS wants to merge 1 commit into
Open
Conversation
Refresh expired Kiro access tokens before unary or streaming generation, coalesce concurrent refreshes, and keep provider-level global refresh slots from leaking across queued credentials.\n\nRefs justlovemaki#680
HanqingAWS
force-pushed
the
fix/kiro-expired-token-refresh
branch
from
August 6, 2026 06:15
3332b73 to
c519c8c
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.
Summary
Why
When a Kiro access token was already expired, both request paths marked the credential as
needsRefreshbut immediately sent the stale token upstream. Kiro then returned:With multiple credentials expiring near the same time, failover selected another expired
credential. The refresh queue also attached global-slot ownership to the first task instead
of the provider queue, so a queued second credential could finish without releasing the
slot. After enough leaked slots, later refreshes never started and all nodes could remain
in “Refreshing” until the service was restarted.
Tests
The tests cover unary ordering, streaming ordering, the near-expiry background path,
concurrent refresh coalescing, provider refresh-slot release, and malformed expiry values.
Fixes #680