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 8/1/2026
Yes, there is. You can inspect the pending queue size using the pendingCount property on the limit function.
According to [index.d.ts:L8-L10], pendingCount is defined as:
The number of promises that are waiting to run (i.e. their internal
fnwas not called yet).
This is a read-only property that gives you the count of tasks queued but not yet executing. For example, from the test in [test.js:L190-L191], you can see it in action:
await Promise.resolve();
t.is(limit.pendingCount, 3);
After queuing tasks, the test checks pendingCount to verify how many are still waiting. This is useful for monitoring queue depth during execution, as shown in the graceful shutdown recipe in [recipes.md:L76-L115].
FOLLOW_UPS:
- How do I clear the pending queue?
- What's the difference between activeCount and pendingCount?
- Can I set a maximum queue size limit?
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.