Skip to content

fix(redis-worker): move unrecoverable queue items to the dead-letter queue#4258

Draft
claude[bot] wants to merge 2 commits into
mainfrom
fix/redis-worker-dlq-invalid-queue-items
Draft

fix(redis-worker): move unrecoverable queue items to the dead-letter queue#4258
claude[bot] wants to merge 2 commits into
mainfrom
fix/redis-worker-dlq-invalid-queue-items

Conversation

@claude

@claude claude Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Overview

SimpleQueue uses a visibility-timeout redelivery model: a dequeued item is re-scored and left in the sorted set, and it only leaves the queue when it is acked or moved to the dead-letter queue (DLQ).

Before: When SimpleQueue.dequeue() encountered an item it could not process — one whose job field was not a string, one whose job had no registered schema, or one whose payload failed schema validation — it logged an error and skipped the item. Because nothing removed it, the item was re-scored and redelivered on the next visibility-timeout cycle, and this repeated on every cycle indefinitely (a poison-message loop).

After: Each of these three cases is unrecoverable — retrying cannot make the item's job or payload valid — so on first encounter the item is moved to the dead-letter queue and never redelivered. This mirrors how the max-attempts path in worker.ts already handles valid-but-failing handlers.

How

In SimpleQueue.dequeue(), the three "invalid item" branches (non-string job, missing schema, failed safeParse) now await this.moveToDeadLetterQueue(id, <reason>) before continue, instead of only logging and skipping. moveToDeadLetterQueue removes the item from the main queue and records its payload and the error in the DLQ. The existing error logs are kept for context.


✅ Checklist

  • I have followed every step in the contributing guide
  • The PR title follows the convention.
  • I ran and tested the code works

Testing

Added tests in packages/redis-worker/src/queue.test.ts covering the unknown-job and unparseable-payload cases: each asserts the item is moved to the DLQ, the main queue is emptied, and the item does not resurface on a subsequent dequeue().


Changelog

SimpleQueue.dequeue() now moves unrecoverable items (invalid job field, unknown job schema, or payload that fails schema validation) to the dead-letter queue on first encounter instead of logging and silently re-queuing them, preventing an indefinite redelivery loop.


Screenshots

N/A

💯


Generated by Claude Code

…queue

SimpleQueue.dequeue() skipped items whose job field was not a string,
whose job had no registered schema, or whose payload failed schema
validation. Because the queue uses a visibility-timeout redelivery model
(items are only removed on ack or by moving them to the DLQ), these
skipped items were re-scored and redelivered on every visibility-timeout
cycle indefinitely.

These failures are unrecoverable, so route all three branches to
moveToDeadLetterQueue() instead of silently skipping. Add tests covering
the unknown-job and unparseable-payload cases.
@changeset-bot

changeset-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6eefa5c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
@trigger.dev/redis-worker Patch
@internal/run-engine Patch
@internal/schedule-engine Patch
@trigger.dev/build Patch
@trigger.dev/core Patch
@trigger.dev/python Patch
@trigger.dev/react-hooks Patch
@trigger.dev/rsc Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/sdk Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@trigger.dev/rbac Patch
@trigger.dev/sso Patch
trigger.dev Patch
@internal/dashboard-agent Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-store Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/sdk-compat-tests Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@d-cs d-cs self-assigned this Jul 14, 2026
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.

2 participants