Repository navigation
Conversation
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.
Logging in through one SDK call could break a pending request from another call, even when they used separate config directories and separate stored logins.
For example, a request starts with login A's credentials, then A refreshes its token. Auth records that the old and new credentials belong to the same login, so the pending request can continue. But logging in through a separate config directory B cleared that record globally. A's request could then fail with
Active credentials changed, even though A's login was still valid.The basic sequential token-switching bug reported in #1391 is already fixed on
main. This PR addresses the remaining shared-state and cleanup problems.Fix
Give each kind of state the lifetime it needs:
flowchart TB subgraph invocation["Invocation: one SDK call and its async work"] context["Captured environment and headers<br/>Temporary routing and cache flags"] request["Request: one HTTP operation<br/>Selected credential snapshot"] context --> request end subgraph session["Session: shared by calls using the same config database"] credentials["Stored login"] refresh["In-memory refresh coordination<br/>and old-to-new credential history"] end credentials -->|Credential snapshot| request request -->|Refresh when needed| refresh refresh -->|Updated token for the same session| request request -->|Explicit request identity and headers| cache["Response cache<br/>Entries scoped by identity"]The session and response cache can outlive a single SDK call. Temporary invocation state stays attached to the call that created it; refresh history is shared only within its credential store.
For streams, cancellation also has to respect that lifetime: a dashboard cancelled during its initial fetch must finish without yielding the fetched value or starting its refresh loop. Iterator return now waits for producer cleanup. The SDK enforces its documented sequential-call contract by rejecting another call until the active invocation finishes cleanup.
Before / after
Active credentials changed.SentryError; it can run after the first finishes cleanup.Fixes #1391.
Validation
pnpm run tscand rootpnpm run lint: pass.pnpm run lintand normal pre-commit hooks: pass.process.env.mainon macOS. The root test command stops at this CLI failure, so subsequent workspace suites were not validated.main; it passed in the final suite. Neither baseline failure is changed here.