{
 "kind": "tool",
 "slug": "p-limit",
 "path": "tools/p-limit/",
 "name": "p-limit",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Utilities",
   "tools/utilities/"
  ]
 ],
 "lead": "Run many slow jobs, only a few at once.",
 "chips": [
  {
   "label": "Utilities",
   "path": "tools/utilities/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install p-limit"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/sindresorhus/p-limit"
  },
  {
   "label": "Website",
   "href": "https://github.com/sindresorhus/p-limit#readme"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software",
   "note": "MIT allows use in paid and closed-source apps.",
   "src": "https://github.com/sindresorhus/p-limit/blob/main/license"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Sep 18, 2026",
   "note": "Latest GitHub release Sep 18, 2026. ",
   "src": "https://github.com/sindresorhus/p-limit"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "29 projects",
   "status": "info",
   "sub": "#49 of 408 in its category",
   "note": "Dependency in 29 public GitHub projects set up for AI coding agents that we scanned (0.5%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 10, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What p-limit does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Fetch many pages, three at a time",
       "text": "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.",
       "idea": false
      },
      {
       "title": "Process a folder of uploads",
       "text": "A batch job reads hundreds of uploaded files; five at a time keeps memory and disk use steady.",
       "idea": false
      },
      {
       "title": "Slow down when a service says wait",
       "text": "When an AI or data service answers \"too many requests\", lower the number of parallel calls on the fly, then raise it again.",
       "idea": false
      },
      {
       "title": "Keep going when some calls fail",
       "text": "One broken link should not stop a run of a thousand; collect the good results and list the failures at the end.",
       "idea": false
      },
      {
       "title": "Show progress of a long run",
       "text": "Print how many jobs are running and how many still wait, so people know a long import is moving.",
       "idea": false
      },
      {
       "title": "Batch AI calls for a spreadsheet",
       "text": "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.",
       "idea": true
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "p-limit popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "66",
       "of": "/ 100",
       "l": "Gid Score, #598 overall"
      },
      {
       "n": "469M",
       "l": "downloads a week, npm"
      },
      {
       "n": "2,943",
       "l": "GitHub stars"
      },
      {
       "n": "29",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How p-limit is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "19 projects, 0.6%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "14 projects, 0.5%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "11 projects, 0.5%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "9 projects, 2.7%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 82.8% of its projects",
       "v": "Vitest",
       "path": "tools/vitest/"
      },
      {
       "l": "In 69.0% of its projects",
       "v": "tsx",
       "path": "tools/tsx/"
      },
      {
       "l": "In 62.1% of its projects",
       "v": "dotenv",
       "path": "tools/dotenv/"
      },
      {
       "l": "In 79.3% of its projects",
       "v": "Zod",
       "path": "tools/zod/"
      },
      {
       "l": "In 100.0% of its projects",
       "v": "TypeScript",
       "path": "tools/typescript/"
      },
      {
       "l": "In 44.8% of its projects",
       "v": "ws",
       "path": "tools/ws/"
      },
      {
       "l": "In 44.8% of its projects",
       "v": "OpenAI",
       "path": "tools/openai-npm/"
      },
      {
       "l": "In 58.6% of its projects",
       "v": "Vite",
       "path": "tools/vite/"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "usage",
   "h2": "More about p-limit",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "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"
       ]
      },
      {
       "title": "More in Utilities",
       "path": "tools/utilities/",
       "items": [
        {
         "text": "clsx",
         "path": "tools/clsx/"
        },
        {
         "text": "date-fns",
         "path": "tools/date-fns/"
        },
        {
         "text": "PyYAML",
         "path": "tools/pyyaml/"
        },
        {
         "text": "uuid",
         "path": "tools/uuid/"
        },
        {
         "text": "yaml",
         "path": "tools/yaml/"
        },
        {
         "text": "js-yaml",
         "path": "tools/js-yaml/"
        },
        {
         "text": "glob",
         "path": "tools/glob/"
        },
        {
         "text": "Lodash",
         "path": "tools/lodash/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "p-limit",
       "me": true,
       "facts": [
        "MIT",
        "Gid 66",
        "469M/wk"
       ]
      },
      {
       "name": "p-queue",
       "why": "Pick p-queue when you need a full queue you can pause, inspect and tune with more options.",
       "path": "tools/p-queue/",
       "facts": []
      },
      {
       "name": "p-map",
       "why": "Pick p-map when you map one list of inputs through one async function and want more options for that case.",
       "path": "tools/p-map/",
       "facts": []
      },
      {
       "name": "p-throttle",
       "why": "Pick p-throttle when the service limits calls per time window rather than calls running at once.",
       "path": "tools/p-throttle/",
       "facts": []
      }
     ],
     "more": "Compare p-limit with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "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."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Add the package (it needs Node.js 20 or newer, or any modern browser via a bundler).",
       "code": "npm install p-limit",
       "src": "https://github.com/sindresorhus/p-limit/blob/main/readme.md"
      },
      {
       "text": "Make a limiter with the number of jobs allowed at once, and wrap each job in it.",
       "code": "import pLimit from 'p-limit';\n\nconst limit = pLimit(1);\n\nconst input = [\n\tlimit(() => fetchSomething('foo')),\n\tlimit(() => fetchSomething('bar')),\n\tlimit(() => doSomething())\n];\n\n// Only one promise is run at once\nconst result = await Promise.all(input);\nconsole.log(result);\n",
       "src": "https://github.com/sindresorhus/p-limit/blob/main/readme.md"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "const pLimit = require('p-limit') in a CommonJS file",
       "fix": "import pLimit from 'p-limit' in an ES module (or const { default: pLimit } = await import('p-limit'))",
       "why": "The package has been ES module only since version 4."
      },
      {
       "dont": "Calling limit(...) again inside a job that is already running under the same limit",
       "fix": "Use a second, separate limiter for inner jobs",
       "why": "The outer jobs hold every slot while they wait for inner jobs that can never start."
      },
      {
       "dont": "limit.clearQueue() while code still awaits Promise.all of the queued jobs",
       "fix": "Create the limiter with pLimit({concurrency: 3, rejectOnClear: true}) so cleared jobs reject with AbortError",
       "why": "Without that option the cleared jobs' promises never settle, so the await hangs."
      },
      {
       "dont": "Using p-limit to keep under \"60 requests per minute\"",
       "fix": "Use p-throttle (calls per time window), or combine it with p-limit",
       "why": "p-limit counts jobs running at the same moment; fast jobs can still exceed a per-minute cap."
      },
      {
       "dont": "Installing p-limit 7 on Node.js 18",
       "fix": "Use Node.js 20 or newer",
       "why": "Version 7 raised the minimum to Node.js 20."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "How is it different from p-queue?",
       "a": "p-limit only caps how many jobs run at once. p-queue is a full queue with more options, inspection and pausing.",
       "evidence": {
        "url": "https://github.com/sindresorhus/p-limit/blob/main/readme.md",
        "quote": "while p-queue is a fully featured queue implementation with lots of different options, introspection, and ability to pause the queue."
       }
      },
      {
       "q": "Can I change the limit while it runs?",
       "a": "Yes. Set limit.concurrency to a new number; the recipes lower it when a service answers 429 and raise it again later.",
       "evidence": {
        "url": "https://github.com/sindresorhus/p-limit/blob/main/readme.md",
        "quote": "Get or set the concurrency limit."
       }
      },
      {
       "q": "Does it work in the browser?",
       "a": "Yes, the readme says it works in Node.js and browsers.",
       "evidence": {
        "url": "https://github.com/sindresorhus/p-limit/blob/main/readme.md",
        "quote": "Works in Node.js and browsers."
       }
      },
      {
       "q": "Are results returned in the order I passed the jobs?",
       "a": "Yes. limit.map works like Promise.all over the inputs, so results keep the input order even when jobs finish in a different order.",
       "evidence": {
        "url": "https://github.com/sindresorhus/p-limit/blob/main/readme.md",
        "quote": "Returns a promise equivalent to Promise.all(Array.from(iterable, (item, index) => limit(mapperFunction, item, index)))"
       }
      },
      {
       "q": "Is it still maintained?",
       "a": "Yes. Version 7.3.3 came out on 2026-09-18 with a fix for limit.map.",
       "evidence": {
        "url": "https://github.com/sindresorhus/p-limit/releases/tag/v7.3.3",
        "quote": "Fix unhandled rejections in limit.map() when the iterable throws"
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm p-limit"
  ],
  [
   "Category",
   "Utilities"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Gid Score",
   "66.2"
  ],
  [
   "Rank in category",
   "#49 of 408"
  ],
  [
   "GitHub",
   "sindresorhus/p-limit"
  ],
  [
   "Last change",
   "Sep 18, 2026"
  ]
 ],
 "good": [
  "It limits how many jobs run at the same moment, not how many start per second. For a per-second cap, use a throttle library.",
  "Do not call the same limiter from inside a job it is already running; the inner job may wait forever.",
  "Clearing the line drops waiting jobs but does not stop jobs that are already running."
 ],
 "checked_line": "Read by AgentGid from 8 official pages, card checked Nov 10, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/sindresorhus.png"
}