How can I check the current number of active tasks?
How can I check the current number of active tasks?
About sindresorhus/p-limit · 2 messages · last activity 5/18/2026
You can check the current number of active tasks using the activeCount property on the limit function.
According to the API documentation [index.d.ts:L1-L6], activeCount is a read-only property that returns "The number of promises that are currently running."
Here's how to use it:
import pLimit from 'p-limit';
const limit = pLimit(5);
// ... queue up some tasks ...
console.log(limit.activeCount); // Check how many are running right now
Similarly, if you want to see how many tasks are waiting to run (not yet executing), you can use the pendingCount property [index.d.ts:L8-L11], which returns "The number of promises that are waiting to run (i.e. their internal fn was not called yet)."
FOLLOW_UPS:
- What's the difference between activeCount and pendingCount?
- How do I dynamically change the concurrency limit?
- Can I monitor when a task completes?
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.