Skip to main content

AsyncQueue

A queue class for limiting concurrent async tasks. This can be used e.g. to prevent race conditions when working on a shared resource such as writing to a database.

Signature

constructor

method(label: string = 'default', concurrency: number = 1) => AsyncQueue

push

method(task: Task<T>) => Promise<T>

Pushes a new task onto the queue, upon which the task will either execute immediately or (if the number of running tasks is equal to the concurrency limit) enqueue the task to be executed at the soonest opportunity.

Was this chapter helpful?
Report Issue
Edited Feb 25, 2026ยทEdit this page