[FEATURE] Add webhook retry mechanism with exponential backoff for failed webhook deliveries
Problem
When a webhook endpoint is temporarily down or returns a non-2xx response, urBackend currently does not retry the delivery. This causes data loss for users relying on webhooks for real-time synchronization (e.g., syncing user signups to CRM, triggering CI pipelines on data changes). A single transient failure permanently drops the event.
Proposed Improvement
Implement an automatic retry mechanism with exponential backoff for failed webhook deliveries. The system should:
- Retry failed webhooks up to 5 times with delays: 1s, 2s, 4s, 8s, 16s
- Store retry state in Redis (attempt count, next retry timestamp)
- Use BullMQ to schedule retry jobs asynchronously
- Mark webhooks as "failed permanently" after max retries and notify the project owner via email
- Expose retry status in the dashboard (pending / retrying / failed / delivered)
- Respect a
Retry-Afterheader if the endpoint returns 429
Expected Impact
- Better reliability for webhook-dependent integrations
- Reduced data loss from transient network failures
- Improved user trust in urBackend's event delivery guarantees
- Better long-term scalability with BullMQ-based job scheduling
Possible Implementation
- Add
webhookRetryQueueinapps/public-api/services/using BullMQ - Extend
WebhookLogschema withretryCount,maxRetries,nextRetryAt,finalStatus - Add
processWebhookRetryworker that re-attempts delivery with exponential backoff - Add
POST /api/webhooks/{id}/retrymanual retry endpoint for dashboard - Update dashboard UI to show retry timeline and status badges
- Write tests for retry logic, backoff timing, and max-retry exhaustion
I'm GSSoC'26 contributor, Please assign this task to me!
/assign
/assign
I think we alredy have exponential retry login on webhooks? @coderabbitai
🏁 Script executed: Length of output: 201012 🏁 Script executed: Length of output: 11964🧩 Analysis chain
#!/bin/bash
set -euo pipefail
echo '=== Issue `#276` ==='
gh issue view 276 --repo geturbackend/urBackend --json number,title,body,state,comments \
--jq '{number,title,state,body,comments:[.comments[]|{author:.author.login,body:.body}]}'
echo
echo '=== Candidate webhook/retry files ==='
fd -HI -t f . | rg -i '(^|/)(webhook|retry|queue|job|delivery|notification)[^/]*\.(ts|tsx|js|jsx|py|go|java|rb|php)$' || true
echo
echo '=== Webhook/retry references (source-like files, excluding dependencies/build output) ==='
rg -n -i -C 4 \
-g '*.{ts,tsx,js,jsx,py,go,java,rb,php}' \
-g '!node_modules/**' -g '!dist/**' -g '!build/**' \
'(exponential|backoff|retry|webhook|webhook.*deliver|deliver.*webhook)' \
. || true
#!/bin/bash
set -euo pipefail
echo '=== Issue `#276` (title and body) ==='
gh api repos/geturbackend/urBackend/issues/276 \
--jq '{number, title, state, body, html_url}'
echo
echo '=== Webhook retry implementation ==='
sed -n '1,330p' packages/common/src/queues/webhookQueue.js
echo
echo '=== Webhook retry tests ==='
rg -n -i -C 3 \
-g '*.{test,spec}.{js,ts,jsx,tsx}' \
-g '!node_modules/**' -g '!dist/**' -g '!build/**' \
'(RETRY_DELAYS|MAX_ATTEMPTS|nextRetryAt|retrying|permanently failed|webhook.*attempt)' \
packages apps || true
@yash-pouranik, yes—the core exponential webhook retry mechanism already exists in packages/common/src/queues/webhookQueue.js.
It uses BullMQ, persists delivery attempts/status in WebhookDelivery, and retries transient failures on this schedule:
- 1 minute
- 5 minutes
- 15 minutes
- 1 hour
- 4 hours
However, #276 is only partially covered:
- HTTP
429is currently treated as a non-retryable 4xx response, soRetry-Afteris not honored. - No project-owner email notification is sent after terminal failure.
- The issue proposes a different backoff schedule (1s → 16s).
- No targeted retry tests were found.
- There is an off-by-one boundary:
attemptNumber <= MAX_ATTEMPTScauses a sixth delivery attempt after the fifth failure.
I’d recommend closing or re-scoping #276 to the missing behavior rather than implementing a second retry system.
invalid issue @Abhushan187