RepoPilot

How can I check the current number of active tasks?

About sindresorhus/p-limit · 2 messages · last activity 6/15/2026

Question

How can I check the current number of active tasks?

RepoPilot

To check the current number of active tasks, you use the activeCount property on the limit function.

According to the TypeScript definitions [index.d.ts:L2-L4], activeCount is:

The number of promises that are currently running.

Here's how you'd use it:

import pLimit from 'p-limit';

const limit = pLimit(5);
console.log(limit.activeCount); // Returns the current number of running promises

A practical example from the recipes is progress reporting [recipes.md:L191-L214], where activeCount is used alongside pendingCount to display the status of queued work:

const progressInterval = setInterval(() => {
	console.log(`Running: ${limit.activeCount}, pending: ${limit.pendingCount}`);
}, 250);

This property is read-only and updates automatically as tasks start and complete.

FOLLOW_UPS:

  • What's the difference between activeCount and pendingCount?
  • How do I clear pending tasks from the queue?
  • Can I set a different concurrency limit later?

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.