Skip to content

refactor: replace p-limit with inline concurrency limiter#1501

Open
roli-lpci wants to merge 2 commits intodanger:mainfrom
roli-lpci:replace-p-limit-with-inline
Open

refactor: replace p-limit with inline concurrency limiter#1501
roli-lpci wants to merge 2 commits intodanger:mainfrom
roli-lpci:replace-p-limit-with-inline

Conversation

@roli-lpci
Copy link

Summary

Replace the p-limit dependency (and its @types/p-limit dev dependency) with a lightweight inline concurrency limiter (~30 lines) in GitHubAPI.ts.

Motivation

  • p-limit v3+ is ESM-only, which creates friction in CJS codebases — the project currently pins ^2.1.0 to avoid this
  • The usage is a single call site: a fixed concurrency of 25 for GitHub API requests
  • Inlining removes 2 dependencies (p-limit + @types/p-limit) with zero behavior change

Changes

  • source/platforms/github/GitHubAPI.ts — Remove p-limit import, add inline pLimit() function with identical queue-based semantics
  • package.json — Remove p-limit from dependencies and @types/p-limit from devDependencies
  • yarn.lock — Updated automatically

Testing

  • tsc --noEmit passes cleanly
  • Production build (tsc -p tsconfig.production.json) compiles successfully
  • No circular dependencies (madge check passes)
  • All 47 GitHub-related unit tests pass

roli-lpci and others added 2 commits February 26, 2026 22:09
Remove the `p-limit` (and `@types/p-limit`) dependency by inlining
a lightweight concurrency limiter directly in GitHubAPI.ts.

The inline implementation (~30 lines) provides the same semantics —
a queue-based promise throttle capped at 25 concurrent requests —
without pulling in an external ESM-only package.
Some callers mock `this.fetch` to return plain objects instead of
Promises. The inline pLimit implementation called `fn().then()`
directly which fails on non-thenable values. Wrapping with
`Promise.resolve()` handles both cases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Member

@orta orta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, nice idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants