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 6/1/2026
You can check the current number of active tasks using the activeCount property of the limit function.
According to the TypeScript definitions [index.d.ts:L2-L4], activeCount is a read-only property that returns "The number of promises that are currently running."
Here's how you'd use it:
import pLimit from 'p-limit';
const limit = pLimit(5);
// Check active tasks
console.log(limit.activeCount); // Number of currently running promises
A practical example from the recipes shows monitoring progress with activeCount [recipes.md:L191-L214]:
const progressInterval = setInterval(() => {
console.log(`Running: ${limit.activeCount}, pending: ${limit.pendingCount}`);
}, 250);
This allows you to track how many tasks are currently executing in real-time while your queue is processing.
FOLLOW_UPS:
- What's the difference between activeCount and pendingCount?
- How do I monitor progress while processing tasks?
- Can I adjust concurrency while tasks are running?
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.