Skip to content

feat: fix y-websocket typing (#972) and implement BullMQ DLQ with ret… - #1008

Open
melvilmz wants to merge 1 commit into
StellarDevHub:mainfrom
melvilmz:fix/y-websocket-and-bullmq-dlq
Open

feat: fix y-websocket typing (#972) and implement BullMQ DLQ with ret…#1008
melvilmz wants to merge 1 commit into
StellarDevHub:mainfrom
melvilmz:fix/y-websocket-and-bullmq-dlq

Conversation

@melvilmz

Copy link
Copy Markdown

Summary of Changes

This PR resolves issues #972 and #989 by addressing TypeScript typing for y-websocket and introducing a Dead-Letter Queue (DLQ) with exponential backoff retries for background jobs.


🚀 Key Improvements

1. Proper Typing for y-websocket (#972)

  • Added local declaration file (src/types/y-websocket.d.ts) covering y-websocket/bin/utils.
  • Updated src/collaborationServer.ts to cleanly import setupWSConnection without requiring @ts-expect-error.

2. BullMQ Dead-Letter Queue & Retries (#989)

  • Retry Strategies:
    • Webhooks Queue: 5 retries with exponential backoff and random jitter.
    • Exports Queue: 3 retries with linear backoff.
  • DLQ Service (src/services/dlq.service.ts):
    • Automatically captures jobs that fail permanently or exhaust all retries.
    • Preserves original job payload, trace ID (traceId), error messages, timestamps, and attempt counts.
    • Logs an error alert when the DLQ depth exceeds the configurable threshold (DLQ_ALERT_THRESHOLD).
  • Admin API Endpoints (src/routes/admin/dlq.routes.ts):
    • GET /admin/dlq: Inspect DLQ records (supports optional queue filter & limit).
    • GET /admin/dlq/metrics: Retrieve DLQ count metrics & alert status.
    • POST /admin/dlq/replay/:dlqId: Replay a specific job back to its original queue.
    • POST /admin/dlq/replay: Replay all jobs (or jobs for a target queue).
    • POST /admin/dlq/purge: Purge DLQ jobs.
  • Unit Tests (tests/dlq.test.ts):
    • Comprehensive unit test suite covering backoff calculations, DLQ enqueuing, payload/traceId preservation, threshold alerts, replay mechanisms, and purging.

🧪 Acceptance Criteria Checklist

  • collaborationServer.ts compiles without @ts-expect-error
  • Failed jobs retry with exponential/linear backoff and configurable max attempts
  • Jobs exceeding retry limit move to DLQ without data loss
  • DLQ is monitorable via depth metrics and threshold alerts
  • Replaying a DLQ job restores it to its original queue with original metadata and traceId
  • Admin endpoints implemented for inspecting, replaying, and purging DLQ records
  • Unit tests written and passing

Related Issues

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

@melvilmz is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@melvilmz 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment