RepoPilot

Is there a way to inspect the pending queue size?

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

Question

Is there a way to inspect the pending queue size?

RepoPilot

Yes, there is. You can use the limit.pendingCount property to inspect how many promises are waiting to run.

According to the README, limit.pendingCount returns "the number of promises that are waiting to run (i.e. their internal fn was not called yet)" [readme.md:L92-L95].

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

import pLimit from 'p-limit';

const limit = pLimit(5);

const urls = getUrls();

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

This shows how you can monitor both active tasks and pending tasks in real-time. The test suite also demonstrates this behavior [test.js:L180-L219], where after enqueueing tasks, you can check limit.pendingCount to verify how many are waiting.

Additionally, there's a complementary property limit.activeCount that shows the number of promises currently running, which is useful for getting a complete picture of queue status.

FOLLOW_UPS:

  • How do I clear pending promises from the queue?
  • What's the difference between activeCount and pendingCount?
  • Can I limit concurrency with an options object?

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.