Repository navigation
Keep the embedded account list when the same principal is published - #342
Merged
joalavedra merged 2 commits intoSep 15, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
joalavedra
deleted the
centaur/fix-wallet-lookup-race-on-login-1789454469
branch
September 15, 2026 16:22
Merged
This was referenced Sep 16, 2026
This branch was successfully 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.
A returning user with existing embedded wallets was routed to wallet creation instead of recovery, and got a brand-new wallet on every login. Reported against
@openfort/react@2.1.1on Solana devnet; reproduced four times in that project's traffic, whereGET /v2/accountsreturned the full list (5, then 6, then 7 wallets, all owned by the same stable user) and was immediately followed byPOST /v2/devices/create. Nothing was lost — the API answered correctly and the SDK threw the answer away.Cause
On
EMBEDDED_SIGNER_NOT_CONFIGURED, the state machine starts the user fetch and the account fetch concurrently.fetchEmbeddedAccountscapturessessionGenerationRefwhen it starts and drops its result if that generation moved by the time the response lands.publishAuthenticatedUsercalledinvalidateSessionWork()on every publication, which bumps that generation and clearsaccountsPending./iam/v2/meanswers in ~30 ms;/v2/accountstakes ~190 ms. The user publication therefore always won: the account list was discarded on arrival,isLoadingAccountsdropped to false before it, andLoadWalletsevaluated an empty store and took the create route. Deterministic, not flaky — which is why it reproduced on every login.Fix
Separate the two things the generation counter was conflating.
The comment on that line states the intent — "any publication supersedes an older user fetch still in flight" — and
userFetchSeqRefis the guard that already covers exactly that. So a publication now bumps the user-fetch sequence only. A full session invalidation is reserved for a genuine change of principal, alongside the wallet-discarding work already in that branch.This also stops an ordinary user refresh from tearing down persistent operations, which
invalidateSessionWorkdid on every publication.Two regression tests, both confirmed to fail when their guard is removed, per
AGENTS.md:isLoadingAccountsstays true until it lands;Verification
pnpm check,check:types,test:types(889),test:unit(870),build,sizeandbuild:docsall pass.Not exercised against a live browser session: the failure is a promise-ordering race inside the provider and is covered at that level, but a devnet sign-in through
<OpenfortButton />with an existing wallet is worth doing before release.Prompted by: Joan Alavedra