Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal-packages/run-engine/src/run-queue/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ describe("RunQueue", () => {
redisTest("Dead Letter Queue", async ({ redisContainer, redisOptions }) => {
const queue = new RunQueue({
...testOptions,
name: "rq-redrive",
retryOptions: {
maxAttempts: 1,
},
Expand Down
24 changes: 20 additions & 4 deletions internal-packages/run-engine/src/run-queue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,16 +671,28 @@ export class RunQueue {
}

public async redriveMessage(env: MinimalAuthenticatedEnvironment, messageId: string) {
// Publish redrive message
await this.redis.publish(
"rq:redrive",
const subscriberCount = await this.redis.publish(
this.#redriveChannel,
JSON.stringify({
runId: messageId,
orgId: env.organization.id,
envId: env.id,
projectId: env.project.id,
})
);

if (subscriberCount === 0) {
this.logger.error(
"redriveMessage: no subscribers on the redrive channel, message remains in the dead letter queue",
{
channel: this.#redriveChannel,
messageId,
orgId: env.organization.id,
envId: env.id,
projectId: env.project.id,
}
);
}
}

public async oldestMessageInQueue(
Expand Down Expand Up @@ -1460,8 +1472,12 @@ export class RunQueue {
);
}

get #redriveChannel() {
return `${this.options.name}:redrive`;
}

async #setupSubscriber() {
const channel = `${this.options.name}:redrive`;
const channel = this.#redriveChannel;
this.subscriber.subscribe(channel, (err) => {
if (err) {
this.logger.error(`Failed to subscribe to ${channel}`, { error: err });
Expand Down