From 89150a7e1280988484e771286f96ddb994248ae9 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 23 Dec 2024 22:53:07 +0000 Subject: [PATCH] Dont block new tasks with old failed ones (#1596) --- packages/provider/src/util.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/provider/src/util.ts b/packages/provider/src/util.ts index 5fa290c6c..462cc7d40 100644 --- a/packages/provider/src/util.ts +++ b/packages/provider/src/util.ts @@ -57,7 +57,10 @@ export async function checkIfTaskIsRunning( taskName, ScheduledTaskStatus.Running, ); - if (runningTask) { + const twoMinutesAgo = new Date().getTime() - 1000 * 60 * 2 + // If the task is running and the task was started within the last 2 minutes + // TODO: This is a temporary fix to prevent failed tasks from blocking the next task + if (runningTask && runningTask.datetime > twoMinutesAgo) { const completedTask = await db.getScheduledTaskStatus( runningTask._id as ObjectId, ScheduledTaskStatus.Completed,