Question
How can I check the current number of active tasks?
About sindresorhus/p-limit · 2 messages · last activity 6/29/2026
How can I check the current number of active tasks?
You can check the current number of active tasks by reading the activeCount property on 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 a usage example:
import pLimit from 'p-limit';
const limit = pLimit(5);
// Queue up some tasks
const promises = [
limit(() => someAsyncTask()),
limit(() => someAsyncTask()),
limit(() => someAsyncTask()),
];
console.log(limit.activeCount); // Shows how many are running right now
This is useful for monitoring the status of your concurrent task queue in real-time.
FOLLOW_UPS:
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.