Skip to content

fix: remove runtime export of type-only RateLimitStorage from ratelimit.cjs#616

Merged
twlite merged 2 commits intomainfrom
copilot/fix-rate-limit-storage-error
Mar 6, 2026
Merged

fix: remove runtime export of type-only RateLimitStorage from ratelimit.cjs#616
twlite merged 2 commits intomainfrom
copilot/fix-rate-limit-storage-error

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

RateLimitStorage is a TypeScript interface — it doesn't exist at runtime. ratelimit.cjs exported it in module.exports without ever importing it, causing ReferenceError: RateLimitStorage is not defined on any import from commandkit/ratelimit.

  • Removed RateLimitStorage from the module.exports object in ratelimit.cjs
  • The type remains accessible to TypeScript consumers via ratelimit.d.ts (export * from './dist/utils/useful-stuff/ratelimiter.js')
Original prompt

This section details on the original issue you should resolve

<issue_title>bug: commandkit/ratelimit throws ReferenceError: RateLimitStorage is not defined on import (v1.2.0)</issue_title>
<issue_description>When importing createRateLimiter from commandkit/ratelimit, CommandKit throws a ReferenceError: RateLimitStorage is not defined before my command can even load. This makes the documented commandkit/ratelimit entrypoint unusable.

Looking at node_modules/commandkit/ratelimit.cjs, it tries to export RateLimitStorage, but that symbol is never defined in the required module (./dist/utils/useful-stuff/ratelimiter.js), which only exports RateLimiter, MemoryRateLimitStorage, etc.

Here's the full stack trace:

✔ Loaded .env
 [INFO]    │ 01:09:50.289 └ CommandKit CachePlugin has been activated!
 [INFO]    │ 01:09:50.302 └ ✨ Loaded event clientReady with 1 listener
 [INFO]    │ 01:09:50.302 └ 🔌 Registered event clientReady (1 sequential, 0 parallel, 0 once-sequential, 0 once-parallel)
 [ERROR]    │ 01:09:50.309 └ Failed to load command verify (04112010-242c-4639-88b8-705085ae1c8a): RateLimitStorage is not defined
ReferenceError: RateLimitStorage is not defined
    at Object.<anonymous> (...\node_modules\.pnpm\commandkit@1.2.0_typescript@5.9.3\node_modules\commandkit\ratelimit.cjs:21:3)
    at Module._compile (node:internal/modules/cjs/loader:1812:14)
    at Object..js (node:internal/modules/cjs/loader:1943:10)
    at Module.load (node:internal/modules/cjs/loader:1533:32)
    at Module._load (node:internal/modules/cjs/loader:1335:12)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
    at loadCJSModuleWithModuleLoad (node:internal/modules/esm/translators:328:3)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:233:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:430:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:661:26)
```</issue_description>

<agent_instructions>`RateLimitStorage` is a typescript type and not a runtime value, so it should not be re-exported from the ratelimit js file. Fix this issue and make sure the code compiles. Do not run the discord bot or anything that opens socket connection. Only attempt the fix and ensure the project builds properly. At the end, make sure to run `pnpm format` command before committing.</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@vercel
Copy link

vercel bot commented Mar 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
commandkit Ready Ready Preview, Comment Mar 6, 2026 2:26pm

…ace from ratelimit.cjs

Co-authored-by: twlite <46562212+twlite@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ReferenceError in commandkit/ratelimit import fix: remove runtime export of type-only RateLimitStorage from ratelimit.cjs Mar 6, 2026
@twlite twlite marked this pull request as ready for review March 6, 2026 14:26
@twlite twlite merged commit 1393c5e into main Mar 6, 2026
2 checks passed
@twlite twlite deleted the copilot/fix-rate-limit-storage-error branch March 6, 2026 14:26
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.

bug: commandkit/ratelimit throws ReferenceError: RateLimitStorage is not defined on import (v1.2.0)

2 participants