Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

p-limit

Run many slow jobs, only a few at once.

UtilitiesNPM

GitHubWebsite

1. License

“to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software”

MIT allows use in paid and closed-source apps.

github.com/sindresorhus/p-limit/blob/main/license

From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error

What p-limit does

p-limit is a tiny free JavaScript library that caps how many slow jobs run at the same time, such as downloads, file reads or calls to an AI service. Other jobs wait in line and start as soon as a slot frees up. Your app stays fast without flooding a server or hitting its limits.

What people build with it

Fetch many pages, three at a time

Your script loads a list of pages or records from a service; it keeps only a few requests open so the service does not block you.

Process a folder of uploads

A batch job reads hundreds of uploaded files; five at a time keeps memory and disk use steady.

Slow down when a service says wait

When an AI or data service answers "too many requests", lower the number of parallel calls on the fly, then raise it again.

Keep going when some calls fail

One broken link should not stop a run of a thousand; collect the good results and list the failures at the end.

Show progress of a long run

Print how many jobs are running and how many still wait, so people know a long import is moving.

Batch AI calls for a spreadsheet Idea

Your assistant writes a script that summarizes 500 rows with an AI service, four requests at a time, to stay within the plan's limits.

p-limit popularity

66 / 100
Gid Score, #598 overall
469M
downloads a week, npm
2,943
GitHub stars
29
agent projects use it
p-limit: downloads per weeknpm, p-limit 469,021,115
p-limit: GitHub starssindresorhus/p-limit 2,943

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How p-limit is used

  • p-limit is a dependency in 29 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (0.6% of the 4,867 JavaScript/TypeScript ones), #49 of 408 in utilities.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 131; those are left out of every share on this page.
  • Projects that use it most often also use Vitest (82.8%), tsx (69.0%), dotenv (62.1%).

By coding agent

19 projects, 0.6%
14 projects, 0.5%
11 projects, 0.5%
9 projects, 2.7%

Often used with

In 82.8% of its projects
In 69.0% of its projects
In 62.1% of its projects
In 79.3% of its projects
In 100.0% of its projects
In 44.8% of its projects
In 44.8% of its projects
In 58.6% of its projects

More about p-limit

Funding
  • GitHub Sponsors: https://github.com/sindresorhus
  • Open Collective: https://opencollective.com/sindresorhus
  • Buy Me a Coffee: https://buymeacoffee.com/sindresorhus
  • Own page: https://sindresorhus.com/donate
  • 186 GitHub sponsors

See all

More in Utilities

Alternatives

p-limit This page

MITGid 66469M/wk

p-queue

Pick p-queue when you need a full queue you can pause, inspect and tune with more options.

p-map

Pick p-map when you map one list of inputs through one async function and want more options for that case.

p-throttle

Pick p-throttle when the service limits calls per time window rather than calls running at once.

Compare p-limit with another tool

Get started

Tell your AI assistant

“Use p-limit 7.3.3 (ES module, Node.js 20+) to run these requests with at most 3 at a time via limit.map, use Promise.allSettled so one failure does not stop the run, and never call the same limit inside a limited job.”

  1. Add the package (it needs Node.js 20 or newer, or any modern browser via a bundler).

    npm install p-limit

    From github.com/sindresorhus/p-limit/blob/main/readme.md

  2. Make a limiter with the number of jobs allowed at once, and wrap each job in it.

    import pLimit from 'p-limit';
    
    const limit = pLimit(1);
    
    const input = [
    	limit(() => fetchSomething('foo')),
    	limit(() => fetchSomething('bar')),
    	limit(() => doSomething())
    ];
    
    // Only one promise is run at once
    const result = await Promise.all(input);
    console.log(result);
    

    From github.com/sindresorhus/p-limit/blob/main/readme.md

Mistakes to avoid

const pLimit = require('p-limit') in a CommonJS file
import pLimit from 'p-limit' in an ES module (or const { default: pLimit } = await import('p-limit'))

The package has been ES module only since version 4.

Calling limit(...) again inside a job that is already running under the same limit
Use a second, separate limiter for inner jobs

The outer jobs hold every slot while they wait for inner jobs that can never start.

limit.clearQueue() while code still awaits Promise.all of the queued jobs
Create the limiter with pLimit({concurrency: 3, rejectOnClear: true}) so cleared jobs reject with AbortError

Without that option the cleared jobs' promises never settle, so the await hangs.

Using p-limit to keep under "60 requests per minute"
Use p-throttle (calls per time window), or combine it with p-limit

p-limit counts jobs running at the same moment; fast jobs can still exceed a per-minute cap.

Installing p-limit 7 on Node.js 18
Use Node.js 20 or newer

Version 7 raised the minimum to Node.js 20.

Questions

How is it different from p-queue?

p-limit only caps how many jobs run at once. p-queue is a full queue with more options, inspection and pausing.

Can I change the limit while it runs?

Yes. Set limit.concurrency to a new number; the recipes lower it when a service answers 429 and raise it again later.

Does it work in the browser?

Yes, the readme says it works in Node.js and browsers.

Are results returned in the order I passed the jobs?

Yes. limit.map works like Promise.all over the inputs, so results keep the input order even when jobs finish in a different order.

Is it still maintained?

Yes. Version 7.3.3 came out on 2026-09-18 with a fix for limit.map.