RepoPilot

How can I check the current number of active tasks?

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

Question

How can I check the current number of active tasks?

RepoPilot

You can check the current number of active tasks using the limit.activeCount property. This returns the number of promises that are currently running.

Here's how to use it:

import pLimit from 'p-limit';

const limit = pLimit(5);

// After queuing some tasks...
console.log(limit.activeCount); // Number of promises currently running

A practical example from the recipes is monitoring progress while work is running [recipes.md:L191-L214]:

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

This allows you to track both active tasks and pending tasks (those waiting to run) at any time.

FOLLOW_UPS:

  • What does pendingCount tell me?
  • How do I cancel pending tasks with clearQueue()?
  • 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.