RepoPilot

How can I check the current number of active tasks?

About sindresorhus/p-limit · 2 messages · last activity 8/1/2026

Question

How can I check the current number of active tasks?

RepoPilot

You can check the current number of active tasks using the activeCount property on the limit function.

According to [index.d.ts:L2-L4], activeCount is defined as:

readonly activeCount: number;

with the description: "The number of promises that are currently running."

Here's a practical example from the recipes [recipes.md:L191-L214]:

import pLimit from 'p-limit';

const limit = pLimit(5);

const urls = getUrls(); // Assume this returns a list of URLs

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

This shows how you can periodically check limit.activeCount to monitor how many promises are actively running at any moment. You can also access it at any time by simply referencing limit.activeCount directly.

FOLLOW_UPS:

  • How do I check pending tasks waiting to run?
  • What's the difference between activeCount and pendingCount?
  • Can I adjust concurrency during execution?

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.