Title: feat(webhooks): cap delivery attempts and dead-letter exhausted deliveries - #67
Open
Emeka000 wants to merge 1 commit into
Open
Title: feat(webhooks): cap delivery attempts and dead-letter exhausted deliveries #67Emeka000 wants to merge 1 commit into
Emeka000 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #45.
Changes
scheduleRetryOrFail() moves a delivery to a new terminal 'dead_letter' state once MAX_ATTEMPTS is exhausted (clears nextRetryAt/lease, sets processingStatus: 'done', records attempt count). SSRF-permanent rejections keep the distinct 'failed' state.
Env-configurable: WEBHOOK_MAX_ATTEMPTS (5), WEBHOOK_BACKOFF_BASE_MS (10000, capped 15 min), plus WEBHOOK_DISPATCH_CONCURRENCY now documented — all in .env.example.
Observability: deadLetterCount in getDispatchMetrics(), listDeadLetterDeliveries() helper, and GET /webhooks/:id/deliveries?status=dead_letter.
Tests in tests/webhooks/dispatcher.test.ts (wired into npm test): backoff schedule, HMAC X-Webhook-Signature, dead-letter transition after the cap.
No schema/migration — dead_letter is a new value of the existing status string.
CI (local): build, validate:prisma, lint (0 errors), typecheck:scripts, check:mock-gating all pass; npm test 216 passing. Pre-existing webhooks-smoke.test.ts failure left untouched (not in the CI test set).
One note
A configured git hook auto-committed the changes during the session and left a stray local branch webhook at that commit. I re-based the work onto a clean feature branch with a proper message; deleting the leftover webhook branch was blocked by the permission classifier, so you may want to run git branch -D webhook yourself.