feat: add expiration for stuck jobs

This commit is contained in:
Nevo David 2025-08-07 23:42:03 +07:00
parent 0d231545ec
commit 889a031e0e
1 changed files with 12 additions and 9 deletions

View File

@ -23,15 +23,18 @@ export const concurrency = async <T>(
});
let load: T;
try {
load = await mapper[strippedIdentifier].schedule<T>(async () => {
return await Promise.race<T>([
new Promise<T>(async (res) => {
await timer(300000);
res(true as T);
}),
func(),
]);
});
load = await mapper[strippedIdentifier].schedule<T>(
{ expiration: 600000 },
async () => {
return await Promise.race<T>([
new Promise<T>(async (res) => {
await timer(300000);
res(true as T);
}),
func(),
]);
}
);
} catch (err) {}
return load;