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 5/25/2026
Yes, you can inspect the pending queue size using the pendingCount property. This property returns the number of promises that are waiting to run (i.e., their internal fn has not been called yet).
According to the type definitions in [index.d.ts:L8-L10], pendingCount is defined as:
/**
The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
*/
readonly pendingCount: number;
This is useful for monitoring queue status. For example, in the recipes documentation [recipes.md:L191-L214], there's a progress reporting example that uses pendingCount along with activeCount to track the state of the limiter:
const progressInterval = setInterval(() => {
console.log(`Running: ${limit.activeCount}, pending: ${limit.pendingCount}`);
}, 250);
This allows you to see both how many promises are currently running and how many are queued up waiting to execute.
FOLLOW_UPS:
- How does activeCount differ from pendingCount?
- Can you modify the concurrency limit dynamically?
- What happens when clearQueue() is called?
Want to ask your own question?
Open chat for sindresorhus/p-limit →Public 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.