Skip to content

[#876] Fix Market Cap blank box during price loading#896

Merged
realproject7 merged 2 commits intomainfrom
task/876-fix-market-cap-loading
Apr 20, 2026
Merged

[#876] Fix Market Cap blank box during price loading#896
realproject7 merged 2 commits intomainfrom
task/876-fix-market-cap-loading

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Switched PLOT/USD price sources from sequential fallback (up to 9s worst case) to Promise.any() parallel fetch — uses whichever source responds first
  • Added DB fallback (trade_history.reserve_usd_rate) so cached price survives serverless cold starts
  • Added structured logging with per-source timing (elapsed=Xms) for diagnosing which sources work/fail
  • MarketCapBox now shows "—" placeholder while loading instead of rendering a blank box

Files Changed

  • lib/usd-price.ts — parallel fetch, DB fallback, structured logging
  • src/components/MarketCapBox.tsx — loading state placeholder
  • package.json — patch bump 0.1.24 → 0.1.25

Test plan

  • Verify Market Cap box shows "—" on initial page load before price arrives
  • Verify Market Cap value populates correctly after price loads
  • Check server logs for [USD Price] source=X result=hit/miss elapsed=Xms entries
  • Confirm price loads significantly faster than before (parallel vs sequential)
  • Cold-start scenario: verify DB fallback kicks in when in-memory cache is empty and external sources are slow

Fixes #876

🤖 Generated with Claude Code

…holder

- Switch price sources from sequential fallback to Promise.any() for parallel fetching
- Add structured logging with per-source timing for diagnostics
- Add DB fallback (trade_history.reserve_usd_rate) to survive serverless cold starts
- Show "—" placeholder in MarketCapBox while PLOT/USD price is loading

Fixes #876

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plotlink Ignored Ignored Apr 20, 2026 10:52pm

Request Review

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: REQUEST CHANGES

Summary

The loading placeholder fix in MarketCapBox is correct, but the new server-side price fetch path still has a blocker. As written, the DB fallback is not guaranteed to run during the exact cold-start / slow-source scenario this PR is trying to fix.

Findings

  • [high] Promise.any() can hang forever because fetchFromMintClub() has no timeout, so fetchPlotUsdPrice() never reaches the DB fallback when Mint Club stalls and the HTTP sources reject.
    • File: lib/usd-price.ts:60
    • Suggestion: wrap the Mint Club SDK path in the same bounded timeout policy as the HTTP fetches, or race each source against a timeout before passing them into Promise.any().
  • [medium] The issue asks for logs that identify why each source failed, but the new catch blocks only emit result=miss with elapsed time and discard the actual failure reason/status.
    • File: lib/usd-price.ts:94
    • Suggestion: log timeout vs HTTP status vs missing data so production logs can distinguish dead sources from transient failures.

Decision

Requesting changes because the main reliability fix is incomplete: if Mint Club hangs, users can still get stuck without a price and without the advertised DB fallback.

- Wrap Mint Club SDK call in Promise.race with 3s timeout to prevent
  Promise.any() from hanging when other sources reject first
- Log failure reason (timeout, http_4xx, no_price_data) for all sources

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: APPROVE

Summary

The rework fixes the blocker from my previous review. fetchFromMintClub() is now bounded by a 3s timeout, so Promise.any() can fail fast and reach the DB fallback, and the source-level logging now captures concrete failure reasons.

Findings

  • No blocking findings in the updated patch.

Decision

Approving from a code-review standpoint. The timeout and logging gaps I raised are addressed in lib/usd-price.ts, and the MarketCapBox placeholder change remains correct.

@realproject7 realproject7 merged commit c370f5d into main Apr 20, 2026
4 checks passed
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.

Market Cap stat box renders blank while PLOT/USD price is loading

2 participants