Skip to content

fix(api): add uncached fetchBountyLive for client polling and claim race refresh (Fixes #863) - #956

Open
Lion4467cat wants to merge 1 commit into
MergeFi:mainfrom
Lion4467cat:fix/issue-863-fetch-bounty-live
Open

Lion4467cat wants to merge 1 commit into
MergeFi:mainfrom
Lion4467cat:fix/issue-863-fetch-bounty-live

Conversation

@Lion4467cat

@Lion4467cat Lion4467cat commented Nov 14, 2026 •

Copy link
Copy Markdown

Fixes #863

What changed

  • Split fetchBounty in src/lib/api.ts into an uncached fetchBountyLive(id, fallback?) function for client-side callers and export const fetchBounty = cache(fetchBountyLive) for React Server Components.
  • Updated src/hooks/bountyPoller.ts and src/hooks/useClaimRace.ts to call fetchBountyLive, and cached PollerEntry.snapshot in bountyPoller.ts so React 19's useSyncExternalStore receives a referentially stable snapshot across renders.
  • Added unit tests in src/lib/api.test.ts and updated src/hooks/useBountyStatus.test.tsx and src/hooks/useClaimRace.test.ts.

Why

  • React.cache() is a Server Component request-memoization primitive; calling it inside the browser polling loop (bountyPoller) and post-409 claim race refresh (useClaimRace) memoized the initial snapshot instead of observing fresh backend state on subsequent ticks.

How to test

  • npx jest src/lib/api.test.ts src/hooks/useBountyStatus.test.tsx src/hooks/useClaimRace.test.ts --no-coverage (3 suites passed, 18 tests passed)
  • npx eslint src/lib/api.ts src/lib/api.test.ts src/hooks/bountyPoller.ts src/hooks/useBountyStatus.ts src/hooks/useBountyStatus.test.tsx src/hooks/useClaimRace.ts src/hooks/useClaimRace.test.ts (0 errors, 0 warnings)

@vercel

vercel Bot commented Nov 14, 2026

Copy link
Copy Markdown

@Lion4467cat is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

@Lion4467cat
Lion4467cat force-pushed the fix/issue-863-fetch-bounty-live branch from 436cb44 to 191e0d1 Compare November 14, 2026 10:41

This branch has not been deployed

No deployments
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.

fetchBounty is wrapped in React cache(), so the client-side bounty poller re-renders the same memoized snapshot forever

1 participant