From 0d3e09e798ad9918a611ab0341d8f72de270cd4b Mon Sep 17 00:00:00 2001 From: Gergo Moricz Date: Fri, 12 Jul 2024 16:35:34 +0200 Subject: [PATCH] fix: try-catch job removal --- apps/api/src/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 818cc5d0..060f6754 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -141,10 +141,14 @@ if (cluster.isMaster) { console.log(" Removing", jobs.length, "jobs..."); await Promise.all(jobs.map(async x => { - await wsq.client.del(await x.lockKey()); - await x.takeLock(); - await x.moveToFailed({ message: "interrupted" }); - await x.remove(); + try { + await wsq.client.del(await x.lockKey()); + await x.takeLock(); + await x.moveToFailed({ message: "interrupted" }); + await x.remove(); + } catch (e) { + console.warn("Failed to remove job", x.id, e); + } })); console.log(" Re-adding", jobs.length, "jobs...");