fix: stop wiping stored connections when a connector registers late - #5746
Merged
Conversation
…-connector branch
… sibling tests The setConnectors retry tests mock ConnectorController.getConnectorId and ChainController.getAccountData at the singleton level. A stray, un-awaited background init promise from an unrelated earlier test can read those mocks mid-test (before afterEach restores them), find a matching connector the retry test just registered for real, and drive a full connect flow that permanently mutates shared controller/provider state, breaking 'should set connected wallet info' several tests later. Flush pending background work before each retry test sets up its mocks, restore the mocks in afterEach, and drain each test's own readyPromise so nothing is left dangling for a later test to pick up.
… sync `setConnectors` also emits synchronously during the adapter's initial `syncConnectors()` call, which runs before `syncExistingConnection()`. The retry therefore fired on ordinary boots too, bypassing `enableReconnect: false` and starting a duplicate concurrent `syncNamespaceConnection` alongside the one the normal boot path already runs. `syncNamespaceConnection` sets status to 'connecting' synchronously before its first await, so requiring status === 'disconnected' (rather than merely !== 'connected') means a retry can only fire after `syncAdapterConnection`'s own guard already ran and found no connector. Also check `enableReconnect` explicitly. Additionally, if a connector never registers (e.g. the extension was uninstalled), the guard used to leave the stale stored connector id forever, permanently breaking `ConnectorController.isConnected()` and silently no-oping `AppKitCore.open()`. A 10s cleanup timer now clears the stale connection, and a successful retry cancels it.
Adds two `setConnectors retry` tests (initial 'connecting' status at boot, `enableReconnect: false`) and two `syncAdapterConnection` tests for the cleanup timer firing and being cancellable. The retry block's afterEach keeps targeted `mockRestore` calls rather than `vi.restoreAllMocks()`: the latter also resets the module-level `vi.fn()` mocks in tests/mocks/Adapter.ts to no-op implementations, and the outer beforeEach only calls `vi.clearAllMocks()`, so five later tests in the file stayed broken. It also resets `OptionsController.enableReconnect`, which the AppKit constructor writes into shared state.
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
🦋 Changeset detectedLatest commit: 60aec0e The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
9 Skipped Deployments
|
Contributor
Visual Regression Test Results ✅ PassedChromatic Build: undefined 👉 Please review the visual changes in Chromatic and accept or reject them. |
Contributor
📦 Bundle Size Check✅ All bundles are within size limits 📊 View detailed bundle sizes> @reown/appkit-monorepo@1.7.1 size /home/runner/work/appkit/appkit > size-limit |
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
0xmkh
reviewed
Aug 16, 2026
Per PR review, revert the generic pending-cleanup/retry mechanism in appkit-base-client.ts and instead have TronAdapter.syncConnectors await pending wallet adapters (e.g. TronLink resolving readyState async) before boot connection sync runs, avoiding the race at its source instead of papering over it generically for every adapter/namespace.
0xmkh
reviewed
Aug 20, 2026
Some wallet adapters may not reliably emit readyStateChanged, so waitForLoadingAdapters now polls adapter.readyState every 200ms via HelpersUtil.withRetry (same pattern as SatsConnectConnector), resolving as soon as the state settles instead of only on the event or the full 3s timeout.
…ion to restore waitForLoadingAdapters previously blocked boot sync on every loading wallet adapter regardless of whether it had anything to restore, adding a multi-second delay to every page load (e.g. TronLink's default readyState check) even when the active session was established via WalletConnect or the adapter isn't installed. Now it only waits for an adapter with an actual stored, non-disconnected TRON connection.
0xmkh
approved these changes
Aug 27, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
useAppKitAccountcould stay permanently disconnected after a reload if the namespace's adapter registers its connectors asynchronously after boot (e.g. an injected wallet extension whosereadyStateresolves later, such asTronLink). Solana, Bitcoin, and Wagmi adapters share the same async-registration shape, so this affects them too, not just TRON.
Root cause:
syncAdapterConnectioncouldn't tell "connector hasn't registered with the adapter yet" apart from "the user disconnected," so it wiped the stored connection (onDisconnectNamespace) the moment boot-timesync ran ahead of the connector showing up. Nothing ever retried once it did.
Fix, entirely in
packages/appkit/src/client/appkit-base-client.ts(no adapter package touched, so every adapter with this shape benefits, not just TRON):syncAdapterConnectionno longer disconnects when a connector hasn't registered yet. It leaves storage intact and schedules a bounded (10s) cleanup in case the connector genuinely never shows up (e.g. the wallet extension was uninstalled).setConnectorsnow retries the namespace sync when a connector matching the stored connector id registers late, while explicitly respectingenableReconnect: falseand not racing the normal boot-time sync (a realgap the whole-branch review caught: every adapter mock in the test suite no-ops
syncConnectors, so this exact race had no prior test coverage).Type of change
Associated Issues
Closes REOWN-4797
Checklist