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/6/2026
Yes, you can inspect the pending queue size using the pendingCount property on the limit function.
According to [index.d.ts:L9-L12], pendingCount is a read-only property that returns "The number of promises that are waiting to run (i.e. their internal fn was not called yet)."
Here's how you'd use it:
import pLimit from 'p-limit';
const limit = pLimit(1);
limit(() => fetchSomething('foo'));
limit(() => fetchSomething('bar'));
limit(() => fetchSomething('baz'));
console.log(limit.pendingCount); // Shows how many tasks are queued
This is demonstrated in the test file [test.js:L186-L188], where it checks that pendingCount correctly reflects the number of pending tasks before and after calling clearQueue().
There's also a companion property activeCount [index.d.ts:L5-L7] if you need to know how many promises are currently running.
FOLLOW_UPS:
- How do activeCount and pendingCount differ?
- Can I dynamically adjust the concurrency limit?
- What happens when clearQueue() is called?
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.