Skip to content

fix(scan): error states for token detail, richlist, and active accounts#102

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/scan-error-states-phase2
Jun 25, 2026
Merged

fix(scan): error states for token detail, richlist, and active accounts#102
github-actions[bot] merged 1 commit into
mainfrom
fix/scan-error-states-phase2

Conversation

@satyakwok

@satyakwok satyakwok commented Jun 25, 2026

Copy link
Copy Markdown
Member

Continues surfacing fetch errors across the explorer (follows #100, #101).

What changed

Four more fetchers now return null on a failed request instead of an empty array, so the hook flags an error instead of the page looking empty: fetchRichlist, fetchTokenHolders, fetchTokenTrades, fetchActiveAccounts. Each is called only by its usePolling hook, which already handles null.

Wired the existing FetchError state into the token detail holders and trades tabs, the top-holders and whale leaderboards, and the most-active accounts list.

Testing

typecheck and build pass. Verified live: with the richlist endpoint failing, the top-holders and whale pages render the retry state instead of an empty list. The active-accounts endpoint is currently responding, so that page shows its normal state.

Not in this PR

/contracts (fetchRecentContracts) uses a direct call with its own error state and needs separate handling. The leaderboard niche fetchers, event logs, and the home Latest Blocks list still swallow errors and can adopt the same pattern.

@github-actions github-actions Bot enabled auto-merge (squash) June 25, 2026 05:32
fetchRichlist, fetchTokenHolders, fetchTokenTrades, and fetchActiveAccounts
returned [] on a failed request; they now return null so the hook flags an
error. Wired the FetchError state into the token detail holders and trades
tabs, the top-holders and whale leaderboards, and the most-active accounts
list.
@satyakwok satyakwok force-pushed the fix/scan-error-states-phase2 branch from dfefcaa to b1f0b75 Compare June 25, 2026 05:34
@satyakwok satyakwok changed the title fix(scan): error states for token detail, richlist, and active accounts (phase 2) fix(scan): error states for token detail, richlist, and active accounts Jun 25, 2026
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

List fetch helpers now return null when the underlying API request fails. The leaderboard account active, leaderboard account holders, leaderboard whale top, and token detail pages now read error and retry values from their data hooks and render FetchError states for failed requests.

Sequence Diagram(s)

sequenceDiagram
  participant TopHoldersPage
  participant useRichlist
  participant fetchRichlist
  participant apiFetch
  participant FetchError
  TopHoldersPage->>useRichlist: request richlist data
  useRichlist->>fetchRichlist: fetchRichlist(network, limit)
  fetchRichlist->>apiFetch: request list endpoint
  apiFetch-->>fetchRichlist: null on failure
  fetchRichlist-->>useRichlist: null
  useRichlist-->>TopHoldersPage: error and retry
  TopHoldersPage->>FetchError: render on error
  FetchError-->>TopHoldersPage: onRetry
  TopHoldersPage->>useRichlist: retry
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Sentriscloud/frontend#100: Changes the same fetch-helper and page-level error handling pattern by returning null on fetch failure and rendering retryable error UI instead of treating failures as empty data.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title matches the PR’s main change: adding error states for scan leaderboard and token detail pages.
Description check ✅ Passed The description covers the summary and testing, and references related work, though it does not follow the template headings exactly.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/scan-error-states-phase2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/scan/app/[locale]/tokens/[addr]/page.tsx (1)

153-159: 🩺 Stability & Availability | 🟡 Minor

Add data-preserving guards to error branches in both tabs.

Loading (tradesLoading && !trades, holdersLoading && !holders) correctly preserves populated rows during background polls, but the error branches (tradesError, holdersError) are currently unconditional. A transient API failure will replace valid data with the retry error screen.

Gating the error display on ... && !data ensures consistent behavior where stale data persists until a successful refresh or initial load failure.

Apply these changes
@@ -(line dependent),-(line dependent) +-(line dependent),-(line dependent) @@
               {tradesLoading && !trades ? (
                 <div className="p-4 space-y-2">
                   {Array.from({ length: 6 }).map((_, i) => <Skeleton key={i} className="h-12 w-full" />)}
                 </div>
-              ) : tradesError ? (
+              ) : tradesError && !trades ? (
                 <FetchError onRetry={retryTrades} />
-
@@ -(line dependent),-(line dependent) +-(line dependent),-(line dependent) @@
               {holdersLoading && !holders ? (
                 <div className="p-4 space-y-2">
                   {Array.from({ length: 6 }).map((_, i) => <Skeleton key={i} className="h-12 w-full" />)}
                 </div>
-              ) : holdersError ? (
+              ) : holdersError && !holders ? (
                 <FetchError onRetry={retryHolders} />
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/scan/app/`[locale]/tokens/[addr]/page.tsx around lines 153 - 159, The
error branches in the token page tabs are unconditional, so a transient failure
can hide already-loaded rows; update the conditional rendering in the trades and
holders sections of page.tsx so FetchError only shows when the corresponding
data array is empty or missing. Use the existing symbols tradesError/trades and
holdersError/holders alongside the loading guards in the same ternary chains to
preserve stale data during background refreshes while still showing the retry
state on initial load failure.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@apps/scan/app/`[locale]/tokens/[addr]/page.tsx:
- Around line 153-159: The error branches in the token page tabs are
unconditional, so a transient failure can hide already-loaded rows; update the
conditional rendering in the trades and holders sections of page.tsx so
FetchError only shows when the corresponding data array is empty or missing. Use
the existing symbols tradesError/trades and holdersError/holders alongside the
loading guards in the same ternary chains to preserve stale data during
background refreshes while still showing the retry state on initial load
failure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b945447-a336-4806-83f8-c945548b89de

📥 Commits

Reviewing files that changed from the base of the PR and between 3ef53eb and dfefcaa.

📒 Files selected for processing (5)
  • apps/scan/app/[locale]/leaderboard/account/active/page.tsx
  • apps/scan/app/[locale]/leaderboard/account/holders/page.tsx
  • apps/scan/app/[locale]/leaderboard/whale/top/page.tsx
  • apps/scan/app/[locale]/tokens/[addr]/page.tsx
  • apps/scan/lib/api.ts

@github-actions github-actions Bot merged commit 95347bb into main Jun 25, 2026
7 checks passed
@satyakwok satyakwok deleted the fix/scan-error-states-phase2 branch June 25, 2026 07:01
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.

1 participant