diff --git a/libraries/helpers/src/utils/concurrency.service.ts b/libraries/helpers/src/utils/concurrency.service.ts index c92b3915..99ee82fa 100644 --- a/libraries/helpers/src/utils/concurrency.service.ts +++ b/libraries/helpers/src/utils/concurrency.service.ts @@ -19,17 +19,19 @@ export const concurrency = async ( maxConcurrent, datastore: 'ioredis', connection, + minTime: 1000, }); let load: T; try { - load = await mapper[strippedIdentifier].schedule( - { expiration: 120_000 }, - async () => { - const res = await func(); - await timer(1000); - return res; - } - ); + load = await mapper[strippedIdentifier].schedule(async () => { + return await Promise.race([ + new Promise(async (res) => { + await timer(300000); + res(true as T); + }), + func(), + ]); + }); } catch (err) {} return load;