Skip to content

fix(hooks): retain live bounty status on transient poll errors (#571) - #580

Open
PINYOPATTANAWASANPORN wants to merge 3 commits into
MergeFi:mainfrom
PINYOPATTANAWASANPORN:fix-use-bounty-status-fallback-571
Open

PINYOPATTANAWASANPORN wants to merge 3 commits into
MergeFi:mainfrom
PINYOPATTANAWASANPORN:fix-use-bounty-status-fallback-571

Conversation

@PINYOPATTANAWASANPORN

@PINYOPATTANAWASANPORN PINYOPATTANAWASANPORN commented Oct 4, 2026 •

Copy link
Copy Markdown

Summary of Changes

  • Updated fetchBounty and useBountyStatus to export and utilize fetchLiveBounty, decision pathing transient network errors/polling failures to retain the latest live data instead of silently regressing to the static fallbackBounty snapshot.
  • Added guard logic in useBountyStatus tracking initial live fetch status (hasLiveRef), preventing transient poll errors from resetting live data or firing false onStatusChange callbacks.
  • Added comprehensive unit test suite in src/hooks/useBountyStatus.test.ts verifying transient poll failure handling.

Root Cause / Technical Context

fetchBounty(bountyId, fallbackBounty) previously caught network/server errors internally and returned { data: fallbackBounty, source: "mock" }. In useSmartPolling, returning mock fallback data as a successful result caused polling state to compare previous live data with the stale fallback, overwriting live state and triggering unwarranted onStatusChange transitions.

Verification & Testing

  • Executed Jest test runner locally with Exit Code 0:
$ npx jest src/hooks/useBountyStatus.test.ts src/components/bounty/BountyStatus.test.tsx src/components/bounty/ClaimButton.test.tsx src/lib/api.test.ts --coverage=false
# PASS src/lib/api.test.ts
# PASS src/components/bounty/BountyStatus.test.tsx
# PASS src/components/bounty/ClaimButton.test.tsx
# PASS src/hooks/useBountyStatus.test.ts
# Test Suites: 4 passed, 4 total
# Tests:       45 passed, 45 total

@vercel

vercel Bot commented Oct 4, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

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.

1 participant