Skip to content

Commit 66083ad

Browse files
committed
fix(run-engine): publish dead-letter redrives to the configured queue channel
redriveMessage published to the hardcoded rq:redrive channel while the subscriber listens on the configured queue name, so redrive silently no-oped for any RunQueue not named rq. Both sides now derive the channel from the queue name, and a redrive that reaches zero subscribers logs an error instead of reporting nothing. Fixes #4854
1 parent 1d55693 commit 66083ad

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

internal-packages/run-engine/src/run-queue/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ describe("RunQueue", () => {
963963
redisTest("Dead Letter Queue", async ({ redisContainer, redisOptions }) => {
964964
const queue = new RunQueue({
965965
...testOptions,
966+
name: "rq-redrive",
966967
retryOptions: {
967968
maxAttempts: 1,
968969
},

internal-packages/run-engine/src/run-queue/index.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,16 +671,28 @@ export class RunQueue {
671671
}
672672

673673
public async redriveMessage(env: MinimalAuthenticatedEnvironment, messageId: string) {
674-
// Publish redrive message
675-
await this.redis.publish(
676-
"rq:redrive",
674+
const subscriberCount = await this.redis.publish(
675+
this.#redriveChannel,
677676
JSON.stringify({
678677
runId: messageId,
679678
orgId: env.organization.id,
680679
envId: env.id,
681680
projectId: env.project.id,
682681
})
683682
);
683+
684+
if (subscriberCount === 0) {
685+
this.logger.error(
686+
"redriveMessage: no subscribers on the redrive channel, message remains in the dead letter queue",
687+
{
688+
channel: this.#redriveChannel,
689+
messageId,
690+
orgId: env.organization.id,
691+
envId: env.id,
692+
projectId: env.project.id,
693+
}
694+
);
695+
}
684696
}
685697

686698
public async oldestMessageInQueue(
@@ -1460,8 +1472,12 @@ export class RunQueue {
14601472
);
14611473
}
14621474

1475+
get #redriveChannel() {
1476+
return `${this.options.name}:redrive`;
1477+
}
1478+
14631479
async #setupSubscriber() {
1464-
const channel = `${this.options.name}:redrive`;
1480+
const channel = this.#redriveChannel;
14651481
this.subscriber.subscribe(channel, (err) => {
14661482
if (err) {
14671483
this.logger.error(`Failed to subscribe to ${channel}`, { error: err });

0 commit comments

Comments
 (0)