01 · Before and afterThe pattern
// before: rely on the queue's id-based dedup
await queue.add(name, data, { jobId: `upgrade.${ws}.${app}` });
// after: check active jobs yourself and return the running one
const running = (await queue.getActive()).find(j => j.id.startsWith(prefix));
if (running) return { jobId: running.id };
if (conflicting.some(op => inFlight(op, ws, app))) throw new UserError(msg);
return queue.add(name, data, { jobId: prefix });02 · Run it on your appThe check
If a user double-clicks “Upgrade” (or two admins click it), how many upgrade jobs run?
If the honest answer is no or not sure, this is worth a look before it reaches production.