Skip to content

feat(webhooks): add dead-letter status and lag metrics to the delivery queue (#165) - #297

Merged
wagmiiii merged 1 commit into
accensa:mainfrom
lorenzo-romano:feat/issue-165-webhook-lag
Aug 29, 2026
Merged

feat(webhooks): add dead-letter status and lag metrics to the delivery queue (#165)#297
wagmiiii merged 1 commit into
accensa:mainfrom
lorenzo-romano:feat/issue-165-webhook-lag

Conversation

@lorenzo-romano

Copy link
Copy Markdown
Contributor

Summary

Completes the two remaining acceptance criteria of #165 for the webhook delivery queue that is already on main (webhooks.ts + webhook_deliveries/webhook_attempts): an explicit dead-letter queue and a lag signal for consumer auto-scaling.

1. Dead-letter queue

  • A delivery that exhausts its attempt budget (MAX_ATTEMPTS) or its 24h delivery window now lands in an explicit dead_letter status instead of a generic failed row — kept for operator inspection, never retried again.
  • webhookSummary counts it (deadLetter) and lists dead-lettered rows in recentFailed.
  • deliverDue counts dead-lettered rows as terminal failures in its run tallies.

2. Lag-based auto-scaling signal

  • New pendingDue() reports the queue's lag: deliveries due for (re)delivery right now.
  • Surfaced in webhookSummary (lag) and in the GET /api/webhooks/deliver response, so a cron scheduler can scale consumer frequency to backlog — when lag stays high, run more frequent/overlapping deliveries; at zero, the queue is drained.

No schema change required: status is a VARCHAR(20) column, so dead_letter fits as-is.

Test Plan

  • New unit tests for pendingDue and webhookSummary (lag + dead-letter accounting) in webhooks.test.ts, following the file's existing fake-client conventions.
  • Existing webhooks.test.ts suites unchanged and compatible (the recordAttempt terminal-state change is covered by the new summary tests).

Closes #165

…y queue (accensa#165)

The webhook delivery queue already retried failed deliveries with exponential
backoff, but gave up silently into a generic 'failed' status with no explicit
dead-letter state, and exposed no lag signal for the consumer fleet to scale
on. This completes those two acceptance criteria:

- Exhausted deliveries now land in an explicit 'dead_letter' status (kept for
  operator inspection, never retried again) instead of a transient-looking
  'failed' row; webhookSummary counts and lists them alongside failures.
- pendingDue() reports the queue's lag — deliveries due for (re)delivery right
  now — surfaced both in the delivery summary and in the /api/webhooks/deliver
  response, so a scheduler can scale consumer frequency to backlog.

Closes accensa#165
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@lorenzo-romano is attempting to deploy a commit to the ACCENSA Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@lorenzo-romano Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@wagmiiii
wagmiiii merged commit 4ebc348 into accensa:main Aug 29, 2026
0 of 10 checks passed
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.

Indexer: Distributed Message Queue for High-Volume Webhooks

2 participants