RepoPilot

How can I check the current number of active tasks?

About sindresorhus/p-limit · 2 messages · last activity 7/13/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 your limit function.

Here's how:

import pLimit from 'p-limit';

const limit = pLimit(5);

// ... queue some tasks ...

console.log(limit.activeCount); // Returns the number of promises currently running

According to the type definitions in [index.d.ts:L2-L4], activeCount is a read-only property that returns "the number of promises that are currently running."

A practical example from [recipes.md:L191-L214] shows how to use this for progress reporting:

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

This allows you to monitor both active tasks (those running right now) and pending tasks (those waiting to run).

FOLLOW_UPS:

  • How do I track pending tasks waiting to run?
  • Can I adjust concurrency limit dynamically at runtime?
  • How do I know when all tasks complete?

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.