RepoPilot

Is there a way to inspect the pending queue size?

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

Question

Is there a way to inspect the pending queue size?

RepoPilot

Yes, you can inspect the pending queue size using the pendingCount property. This is a read-only property on the limit function that returns the number of promises waiting to run (i.e., their internal function has not been called yet) [index.d.ts:L8-L11].

Here's how you'd use it:

import pLimit from 'p-limit';

const limit = pLimit(1);

limit(() => fetchSomething('foo'));
limit(() => fetchSomething('bar'));
limit(() => fetchSomething('baz'));

console.log(limit.pendingCount); // Shows how many are queued

The pendingCount property is distinct from activeCount [index.d.ts:L3-L6], which shows how many promises are currently running. Together, these give you full visibility into the state of the queue—activeCount tells you what's executing, and pendingCount tells you what's waiting.

There's also limit.activeCount for monitoring actively running tasks [index.d.ts:L3-L6].

FOLLOW_UPS:

  • What's the difference between activeCount and pendingCount?
  • Can you clear pending promises from the queue?
  • How do you monitor queue state changes over time?

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.