fix(rewards): add retry on snapshot load failure + tab-switch logging#768
Conversation
First slice of tinyhumansai#712 (Rewards stabilization). Keeps scope to the page shell so follow-up PRs can focus on per-tab flows (referrals, redeem, community/Discord) and E2E coverage. - Extract loadRewards into a useCallback so retry can re-trigger it. - Render a "Try again" button in the Community tab's error banner with data-testid="rewards-retry" for upcoming E2E. Disabled while the retry is in flight. - Log tab transitions and retry requests under the [rewards] prefix. - Extend Rewards.test.tsx with a retry test (fail -> click -> refetch -> success renders achievements, error banner disappears). cc @M3gA-Mind (assignee on tinyhumansai#712) — happy to hand off or coordinate the remaining slices.
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 43 minutes and 26 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
…tinyhumansai#768) Co-authored-by: Jwalin Shah <jshah1331@gmail.com>
Summary
First slice of #712 (Rewards stabilization). Tight, review-in-one-sitting change on the Rewards page shell so follow-up PRs can focus on per-tab flows and E2E.
[rewards]prefix.cc @M3gA-Mind — you're the assignee on #712, happy to hand off or coordinate remaining slices. Scoped this PR to the page shell specifically so it doesn't block whatever you're doing on the individual tabs.
Problem
Rewards.tsxhad no retry path: if thegetMyRewardscall failed at mount, the user was stuck with a yellow banner and had to reload the whole app. The error string also wasn't easy to surface for E2E or Sentry.Solution
loadRewardsinto auseCallbackso it can be invoked from both the mountuseEffectand a user-triggered retry.onRetryintoRewardsCommunityTab; render aTry againpill inside the existing amber banner. Usesdata-testid="rewards-error"/data-testid="rewards-retry"so the upcoming E2E slice of Stabilize Rewards page end-to-end (Referrals, Rewards, Redeem) with full test coverage #712 has stable hooks.errorand setisLoadingat the start of every fetch so retry visibly "goes back to loading" instead of lingering on the failed state.[rewards] fetching snapshot,[rewards] tab changed,[rewards] retry requestedfor ops / Sentry breadcrumbs.Explicitly not in scope (deferred to subsequent #712 slices):
rewards-error,rewards-retry); specs will land in the E2E slice.Remaining #712 plan
Each slice is independent and passes CI on its own; #712 stays open until the E2E slice lands.
Submission Checklist
yarn test:unit src/pages/__tests__/Rewards.test.tsx→ 5 passed (1 new).yarn compileclean.yarn lint+ Prettier clean.Impact
Related