From 889a031e0e7e578c8c6484fb7504d5975b2293b7 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Thu, 7 Aug 2025 23:42:03 +0700 Subject: [PATCH] feat: add expiration for stuck jobs --- .../helpers/src/utils/concurrency.service.ts | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/libraries/helpers/src/utils/concurrency.service.ts b/libraries/helpers/src/utils/concurrency.service.ts index 99ee82fa..88417d95 100644 --- a/libraries/helpers/src/utils/concurrency.service.ts +++ b/libraries/helpers/src/utils/concurrency.service.ts @@ -23,15 +23,18 @@ export const concurrency = async ( }); let load: T; try { - load = await mapper[strippedIdentifier].schedule(async () => { - return await Promise.race([ - new Promise(async (res) => { - await timer(300000); - res(true as T); - }), - func(), - ]); - }); + load = await mapper[strippedIdentifier].schedule( + { expiration: 600000 }, + async () => { + return await Promise.race([ + new Promise(async (res) => { + await timer(300000); + res(true as T); + }), + func(), + ]); + } + ); } catch (err) {} return load;