diff --git a/packages/queue/src/utils.ts b/packages/queue/src/utils.ts index 33c675eb..c9e0b23f 100644 --- a/packages/queue/src/utils.ts +++ b/packages/queue/src/utils.ts @@ -5,13 +5,14 @@ export async function findJobByPrefix( keys: string[], matcher: string ) { - const filtered = keys.filter((key) => key.includes(matcher)); const getTime = (val?: string) => { if (!val) return null; const match = val.match(/:(\d+)$/); return match?.[1] ? parseInt(match[1], 10) : null; }; - + const filtered = keys + .filter((key) => key.includes(matcher)) + .filter((key) => getTime(key)); filtered.sort((a, b) => { const aTime = getTime(a); const bTime = getTime(b);