Skip to content

[#393] Fix RPC race condition + browser client routing#394

Merged
realproject7 merged 2 commits intomainfrom
task/393-fix-rpc-race
Mar 20, 2026
Merged

[#393] Fix RPC race condition + browser client routing#394
realproject7 merged 2 commits intomainfrom
task/393-fix-rpc-race

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  1. Batch ready gating: BatchTokenDataProvider now exposes isReady flag. StoryCardTVL waits for batch to settle before enabling individual fallback queries — prevents race where individual calls fire before batch multicall arrives.

  2. Browser client routing: getTokenPrice(), getTokenTVL(), and get24hPriceChange() now accept optional client parameter. All browser components pass browserClient for CORS-safe RPC access. Server-side callers use default publicClient (unchanged).

Updated files

  • lib/price.ts — optional client param on 3 functions
  • src/components/BatchTokenDataProvider.tsx — isReady context flag
  • src/components/StoryCardStats.tsx — batch gating + browserClient
  • src/components/WriterTradingStats.tsx — browserClient
  • src/components/ClaimRoyalties.tsx — browserClient
  • src/components/ReaderPortfolio.tsx — browserClient
  • src/app/dashboard/writer/page.tsx — browserClient

Fixes #393

Test plan

  • npm run typecheck — passes
  • npm run lint — passes
  • Manual: no 429 errors in browser console on home page

🤖 Generated with Claude Code

…ient

1. BatchTokenDataProvider now exposes isReady flag. StoryCardTVL
   waits for batch to settle before enabling individual fallback,
   preventing race where individual calls fire before batch arrives.

2. getTokenPrice/getTokenTVL/get24hPriceChange accept optional
   client parameter. All browser components pass browserClient
   for CORS-safe RPC access. Server-side callers unchanged.

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.

LGTM. isReady gating correctly prevents race — individual fallback only fires after batch settles. All browser-side price/TVL functions now routed through browserClient. CI green.

Minor (not blocking): ClaimRoyalties.tsx, WriterTradingStats.tsx, and ReaderPortfolio.tsx have duplicate import lines from lib/rpc (browserClient as publicClient + browserClient). Could be merged into one import statement.

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 race-condition gating and browser-client routing fixes are in place on the latest head, and CI is green.

Findings

  • None.

Decision

Approved. The batch provider now exposes readiness state, browser-side individual reads use browserClient, and the latest lint-and-typecheck run passed.

@realproject7 realproject7 merged commit d5acb79 into main Mar 20, 2026
1 check passed
@realproject7 realproject7 deleted the task/393-fix-rpc-race branch March 20, 2026 20:36
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.

[Bug] Individual price/TVL calls still bypass RPC fallback — race condition + wrong client

2 participants