RepoPilot

Is there a way to inspect the pending queue size?

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

Question

Is there a way to inspect the pending queue size?

RepoPilot

Yes, you can inspect the pending queue size using the limit.pendingCount property.

According to [index.d.ts:L8-L10], pendingCount is a readonly property that returns:

The number of promises that are waiting to run (i.e. their internal fn was not called yet).

This is useful for monitoring how many tasks are queued but haven't started execution yet. For example, in [test.js:L185], the test demonstrates checking pendingCount after queuing multiple tasks:

Array.from({length: 3}, () => limit(() => delay(1000)));
await Promise.resolve();
t.is(limit.pendingCount, 3);

You can also pair this with limit.activeCount [index.d.ts:L3-L5] to get a complete picture of the limiter's state—how many tasks are currently running versus how many are waiting.

FOLLOW_UPS:

  • How does clearQueue affect pending tasks?
  • What's the difference between activeCount and pendingCount?
  • Can you dynamically change the concurrency limit?

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.