Skip to content

feat: Add background retry for pending claim disbursements#523

Open
Menjay7 wants to merge 2 commits into
Pulsefy:mainfrom
Menjay7:main
Open

feat: Add background retry for pending claim disbursements#523
Menjay7 wants to merge 2 commits into
Pulsefy:mainfrom
Menjay7:main

Conversation

@Menjay7
Copy link
Copy Markdown

@Menjay7 Menjay7 commented May 29, 2026

PR Description
Overview

This PR introduces a background retry mechanism for pending claim submissions to improve reliability and ensure failed or delayed claim operations are retried automatically.

Problem

Pending claim submissions could remain unresolved due to:

temporary network failures
downstream service interruptions
timeout issues
intermittent processing errors

Without an automated retry mechanism, these claims required manual intervention or risked remaining permanently unprocessed.

Changes Made
Added background worker/process for retrying pending claim submissions
Implemented retry scheduling and status tracking logic
Added configurable retry intervals and retry limits
Improved handling of transient submission failures
Added safeguards to prevent duplicate processing
Refactored claim state transitions for more reliable recovery behavior
Benefits
Improves reliability of claim processing workflows
Reduces manual operational intervention
Prevents claims from becoming permanently stuck
Enhances resilience against temporary infrastructure failures
Improves overall user experience and submission consistency
Testing
Verified failed claims are retried automatically
Tested retry backoff and retry limit behavior
Confirmed successful claims are not retried unnecessarily
Validated duplicate processing protections
Ensured no regression in existing claim submission flows...Closed #451

- Add 'disbursing' status to ClaimStatus enum
- Modify disburse method to enqueue background jobs with BullMQ
- Add ClaimRetryService to monitor and handle stuck disbursements
- Update on-chain processor to transition claim status on success/failure
- Add automatic retry with exponential backoff (5 attempts)
- Add monitoring cron job running every 5 minutes
- Revert claims to 'approved' after max retry attempts
- Add @ratelimit decorator for endpoint-specific configuration
- Create CostAwareRateLimitGuard with cost-aware rate limiting
- Implement automatic cost calculation based on HTTP method and path
- Add rate limit headers (Limit, Remaining, Reset, Cost, Window)
- Apply rate limits to claims endpoints (create, disburse)
- Apply rate limits to verification endpoint (enqueue)
- Add comprehensive documentation

Default costs:
- Read operations: 1
- Write operations: 5
- Expensive operations (on-chain): 20
- Bulk operations: 50
@Cedarich
Copy link
Copy Markdown
Contributor

Please fix the workflow

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.

Background Retry for Pending Claim Submissions

3 participants