Skip to content

Add withRetry utility and retry user upsert on transient failures#922

Merged
jbojcic1 merged 2 commits intomasterfrom
feat/with-retry-util
Mar 5, 2026
Merged

Add withRetry utility and retry user upsert on transient failures#922
jbojcic1 merged 2 commits intomasterfrom
feat/with-retry-util

Conversation

@jbojcic1
Copy link
Collaborator

@jbojcic1 jbojcic1 commented Mar 5, 2026

Summary

  • Add reusable withRetry utility (app/lib/with-retry.ts) with exponential backoff (500ms, 1s, 2s, ... capped at 30s), configurable retry count or predicate, custom retry delay function, and abort signal support
  • Wrap user upsert in _protected.tsx middleware with withRetry to handle transient network failures (fixes AGICASH-7D)
  • Replace fetchQuery with withRetry for mint quote check in cashu-receive-quote-hooks.ts
  • Unexport userQueryOptions in user-hooks.tsx

Test plan

  • Verify app loads normally (upsert succeeds on first try)
  • Verify retry behavior by simulating network failure (e.g. throttle network in DevTools)
  • Verify ZodError is not retried

Resolves https://make-prisms.sentry.io/issues/7310936806/?alert_rule_id=16176971&alert_type=issue&environment=production&notification_uuid=1f60e2dd-cfdf-49e3-867a-8b566da31fca&project=4509707316690944&referrer=discord

@jbojcic1 jbojcic1 requested a review from gudnuf March 5, 2026 11:11
@jbojcic1 jbojcic1 self-assigned this Mar 5, 2026
@vercel
Copy link

vercel bot commented Mar 5, 2026

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

Project Deployment Actions Updated (UTC)
agicash Ready Ready Preview, Comment Mar 5, 2026 10:04pm

Request Review

@supabase
Copy link

supabase bot commented Mar 5, 2026

This pull request has been ignored for the connected project hrebgkfhjpkbxpztqqke because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Copy link
Collaborator Author

@jbojcic1 jbojcic1 Mar 5, 2026

Choose a reason for hiding this comment

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

I added this so we can use it in places where we just need retires without the cache logic. We could have done this with react query fetchQuery (how it was before this change in cashu-receive-quote-hooks file where we had queryKey: ['check-mint-quote', receiveQuote.quoteId],) but if we do those we have these temp cache entries (we have to have some query key, gcTime and staleTime 0) which is a bit awkward

jbojcic1 and others added 2 commits March 5, 2026 23:03
Fixes AGICASH-7D

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jbojcic1 jbojcic1 force-pushed the feat/with-retry-util branch from 2f66233 to 6c04b0e Compare March 5, 2026 22:03
@jbojcic1 jbojcic1 merged commit 15dffc1 into master Mar 5, 2026
5 checks passed
@jbojcic1 jbojcic1 deleted the feat/with-retry-util branch March 5, 2026 22:04
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.

2 participants