From f25d88aac289b8b0f2f830368dbd09b78bfae803 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 15:21:51 +0000 Subject: [PATCH 1/4] Initial plan From ef375b23f8cda302c01483c1bea5d927e799d54b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 15:24:11 +0000 Subject: [PATCH 2/4] Rename max_retries to max_attempts for clarity Co-authored-by: emilioSp <22614105+emilioSp@users.noreply.github.com> --- migrations/20260128113327_add_retry_logic.ts | 4 ++-- src/consumer.ts | 8 ++++---- src/types.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/migrations/20260128113327_add_retry_logic.ts b/migrations/20260128113327_add_retry_logic.ts index 5fe537b..66aaad5 100644 --- a/migrations/20260128113327_add_retry_logic.ts +++ b/migrations/20260128113327_add_retry_logic.ts @@ -6,7 +6,7 @@ export async function up(knex: Knex): Promise { `ALTER TABLE tasks ADD COLUMN retry_count INTEGER NOT NULL DEFAULT 0;`, ); await knex.raw( - `ALTER TABLE tasks ADD COLUMN max_retries INTEGER NOT NULL DEFAULT 3;`, + `ALTER TABLE tasks ADD COLUMN max_attempts INTEGER NOT NULL DEFAULT 3;`, ); await knex.raw(`ALTER TABLE tasks ADD COLUMN error_message TEXT;`); @@ -15,7 +15,7 @@ export async function up(knex: Knex): Promise { export async function down(knex: Knex): Promise { await knex.raw(`ALTER TABLE tasks DROP COLUMN retry_count;`); - await knex.raw(`ALTER TABLE tasks DROP COLUMN max_retries;`); + await knex.raw(`ALTER TABLE tasks DROP COLUMN max_attempts;`); await knex.raw(`ALTER TABLE tasks DROP COLUMN error_message;`); await knex.raw(`ALTER TYPE t_status REMOVE VALUE 'failed';`); diff --git a/src/consumer.ts b/src/consumer.ts index d5f92ec..d55d1f9 100644 --- a/src/consumer.ts +++ b/src/consumer.ts @@ -30,8 +30,8 @@ while (true) { } catch (error) { const newRetryCount = task.retry_count + 1; - if (newRetryCount >= task.max_retries) { - // Max retries exceeded, mark as failed + if (newRetryCount >= task.max_attempts) { + // Max attempts exceeded, mark as failed await db('tasks') .update({ status: 'failed', @@ -42,7 +42,7 @@ while (true) { .where({ id: task.id }); console.log( - `❌ Task failed permanently after ${newRetryCount} retries:`, + `❌ Task failed permanently after ${newRetryCount} attempts:`, task.id, ); } else { @@ -56,7 +56,7 @@ while (true) { .where({ id: task.id }); console.log( - `🔄 Task failed, retry ${newRetryCount}/${task.max_retries}:`, + `🔄 Task failed, attempt ${newRetryCount}/${task.max_attempts}:`, task.id, ); } diff --git a/src/types.ts b/src/types.ts index 56e4646..85fa452 100644 --- a/src/types.ts +++ b/src/types.ts @@ -7,7 +7,7 @@ export type Task = { payload: Payload; status: 'pending' | 'in_progress' | 'done' | 'failed'; retry_count: number; - max_retries: number; + max_attempts: number; error_message: string | null; created_at: string; picked_at: string | null; From 026756b92ef13df52d223684d4c33c87a424f0ef Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 15:26:10 +0000 Subject: [PATCH 3/4] Clarify log messages and fix migration down function Co-authored-by: emilioSp <22614105+emilioSp@users.noreply.github.com> --- migrations/20260128113327_add_retry_logic.ts | 2 +- src/consumer.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migrations/20260128113327_add_retry_logic.ts b/migrations/20260128113327_add_retry_logic.ts index 66aaad5..326a8de 100644 --- a/migrations/20260128113327_add_retry_logic.ts +++ b/migrations/20260128113327_add_retry_logic.ts @@ -18,6 +18,6 @@ export async function down(knex: Knex): Promise { await knex.raw(`ALTER TABLE tasks DROP COLUMN max_attempts;`); await knex.raw(`ALTER TABLE tasks DROP COLUMN error_message;`); - await knex.raw(`ALTER TYPE t_status REMOVE VALUE 'failed';`); // Note: PostgreSQL doesn't support removing values from enums easily + // The 'failed' value will remain in t_status enum } diff --git a/src/consumer.ts b/src/consumer.ts index d55d1f9..64740ed 100644 --- a/src/consumer.ts +++ b/src/consumer.ts @@ -42,7 +42,7 @@ while (true) { .where({ id: task.id }); console.log( - `❌ Task failed permanently after ${newRetryCount} attempts:`, + `❌ Task failed permanently (${newRetryCount} failures):`, task.id, ); } else { @@ -56,7 +56,7 @@ while (true) { .where({ id: task.id }); console.log( - `🔄 Task failed, attempt ${newRetryCount}/${task.max_attempts}:`, + `🔄 Task failed (failure ${newRetryCount}/${task.max_attempts}):`, task.id, ); } From 1bcbcdefad9b1f947c24a985243e2960128552c1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 15:28:15 +0000 Subject: [PATCH 4/4] Improve migration down function comment Co-authored-by: emilioSp <22614105+emilioSp@users.noreply.github.com> --- migrations/20260128113327_add_retry_logic.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/20260128113327_add_retry_logic.ts b/migrations/20260128113327_add_retry_logic.ts index 326a8de..e5289da 100644 --- a/migrations/20260128113327_add_retry_logic.ts +++ b/migrations/20260128113327_add_retry_logic.ts @@ -19,5 +19,5 @@ export async function down(knex: Knex): Promise { await knex.raw(`ALTER TABLE tasks DROP COLUMN error_message;`); // Note: PostgreSQL doesn't support removing values from enums easily - // The 'failed' value will remain in t_status enum + // The 'failed' value will remain in t_status enum, only the added columns are rolled back }