RepoPilot

Is there a way to inspect the pending queue size?

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

Question

Is there a way to inspect the pending queue size?

RepoPilot

Yes, there is. You can inspect the pending queue size using the limit.pendingCount property.

According to the API documentation [index.d.ts:L8-L11], pendingCount is a read-only property that returns "The number of promises that are waiting to run (i.e. their internal fn was not called yet)."

Here's a practical example from the test suite [test.js:L187-L189]:

const limit = pLimit(1);

Array.from({length: 1}, () => limit(() => delay(1000)));
Array.from({length: 3}, () => limit(() => delay(1000)));

await Promise.resolve();
t.is(limit.pendingCount, 3);  // Inspect the pending queue size

This allows you to see how many tasks are queued up and waiting to execute. Additionally, you can also inspect limit.activeCount [index.d.ts:L3-L5] to see how many promises are currently running.

FOLLOW_UPS:

  • How do I clear the pending queue?
  • What's the difference between activeCount and pendingCount?
  • Can I modify the concurrency limit dynamically?

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.