Resolve the process-wide queue, creating or resizing it only when needed.
Passing the same concurrency again must return the existing queue. Creating
a fresh one per call looked equivalent but was the opposite of the intent: a
handler that writes queued(job, { concurrency: 2 }) on every request would
get a new, empty queue each time, so every job started immediately and the cap
was never enforced — precisely the unbounded fan-out this module exists to
prevent. Verified: 10 jobs at concurrency: 2 reached a peak of 10 before this
was fixed.
Resolve the process-wide queue, creating or resizing it only when needed.
Passing the same
concurrencyagain must return the existing queue. Creating a fresh one per call looked equivalent but was the opposite of the intent: a handler that writesqueued(job, { concurrency: 2 })on every request would get a new, empty queue each time, so every job started immediately and the cap was never enforced — precisely the unbounded fan-out this module exists to prevent. Verified: 10 jobs atconcurrency: 2reached a peak of 10 before this was fixed.