Skip to content

sdk: show error state on balance fetch failure#214

Open
andrewliu08 wants to merge 1 commit intomasterfrom
wallet-balance-error-ui
Open

sdk: show error state on balance fetch failure#214
andrewliu08 wants to merge 1 commit intomasterfrom
wallet-balance-error-ui

Conversation

@andrewliu08
Copy link
Copy Markdown
Member

@andrewliu08 andrewliu08 commented Mar 3, 2026

Summary

  • Add balanceError state and retryBalances callback to useWalletFlow
  • Show error message + retry button in SelectTokenPage instead of infinite skeleton rows
  • When clientSecret is missing or API errors occur, fetchBalances now sets an error state instead of silently failing

Context

After connecting a wallet on /session/:id, if ?cs= is missing from the URL or the API returns an error, fetchBalances silently failed — balances stayed null forever and the UI showed infinite skeleton loading rows. Now users see an error message with a retry button and contact support link.

Test plan

  • Connect wallet on /session/:id?cs=<valid> — token options load normally
  • Navigate to /session/:id without ?cs= — error message shown instead of infinite skeletons
  • Use invalid clientSecret — error with retry button shown
  • Click retry button — re-attempts balance fetch

🤖 Generated with Claude Code


Open with Devin

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

…ailure

When fetchBalances fails (missing clientSecret or API error), the token
selection page showed infinite skeleton loading rows. Add balanceError
state and retryBalances callback to useWalletFlow, and render an error
message with retry button in SelectTokenPage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@andrewliu08 andrewliu08 force-pushed the wallet-balance-error-ui branch from 687241c to 4f5b3fc Compare March 3, 2026 23:35
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 7 additional findings in Devin Review.

Open in Devin Review

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Stale balanceError shown instead of loading skeleton on account switch after failure

When a balance fetch fails (setting balanceError), and the user then switches wallet accounts (triggering handleAccountsChanged), the old error message is shown instead of a loading skeleton while the new account's balances are being fetched.

Root Cause

The fetchBalances function does not clear balanceError when it begins a new non-cached fetch (around line 123). Meanwhile, the handleAccountsChanged handler at useWalletFlow.ts:296-323 calls fetchBalances(updated, true) without clearing balanceError either.

In SelectTokenPage.tsx:44, the error check takes priority over the isLoading check at line 65:

if (error) { return error UI; }        // line 44 — wins
if (isLoading || options === null) { ... } // line 65 — never reached

So when isLoadingBalances=true AND balanceError is still set from a previous failed fetch for a different wallet, the user sees the stale error instead of loading skeletons.

The retryBalances callback correctly clears the error before re-fetching (useWalletFlow.ts:252), but the handleAccountsChanged and handleAccountChanged (Solana) paths at useWalletFlow.ts:296-323 and useWalletFlow.ts:336-355 do not.

Impact: After a balance fetch failure, switching accounts in the wallet extension shows the old error message instead of a loading state for the new account.

(Refers to line 123)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

isConnecting: boolean;
isLoadingBalances: boolean;
connectError: string | null;
balanceError: string | null;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do connectError and balanceError render differently?

can we treat them symmetrically?

setBalanceError("missing authentication");
setIsLoadingBalances(false);
return;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants