Is there a way to inspect the pending queue size?
Is there a way to inspect the pending queue size?
About sindresorhus/p-limit · 2 messages · last activity 7/13/2026
Yes, there is. You can inspect the pending queue size using the pendingCount property on the limit function.
According to the TypeScript definitions [index.d.ts:L8-L10], pendingCount is a read-only property that represents:
"The number of promises that are waiting to run (i.e. their internal
fnwas not called yet)."
Here's a practical example from the test suite [test.js:L180-L190]:
const limit = pLimit(1);
Array.from({length: 1}, () => limit(() => delay(1000)));
Array.from({length: 3}, () => limit(() => delay(1000)));
await Promise.resolve();
t.is(limit.pendingCount, 3); // Check the pending count
limit.clearQueue();
t.is(limit.pendingCount, 0);
This is useful for monitoring how many tasks are queued and waiting to execute. The library also provides activeCount [index.d.ts:L4-L6] if you need to know how many promises are currently running.
FOLLOW_UPS:
- What does activeCount tell you about running tasks?
- How can you dynamically change the concurrency limit?
- What happens when you call clearQueue with rejectOnClear enabled?
Want to ask your own question?
Open chat for sindresorhus/p-limitPublic Q&A. Generated by RepoPilot from the actual source of sindresorhus/p-limit. AI answers can be incomplete or stale — verify before relying on them.