Skip to content

fix(rateLimiter): await async checkRateLimit in getAllRateLimits + ad…#82

Open
Div1912 wants to merge 1 commit into
mericcintosun:mainfrom
Div1912:fix/ratelimiter-unresolved-promise-and-ssr-crash
Open

fix(rateLimiter): await async checkRateLimit in getAllRateLimits + ad…#82
Div1912 wants to merge 1 commit into
mericcintosun:mainfrom
Div1912:fix/ratelimiter-unresolved-promise-and-ssr-crash

Conversation

@Div1912

@Div1912 Div1912 commented Apr 30, 2026

Copy link
Copy Markdown

Summary

Two bugs fixed in src/lib/rateLimiter.js:

Bug 1 - Unawaited async call in getAllRateLimits()

getAllRateLimits() called checkRateLimit(walletAddress) - an async function - without await. This meant each status field in the returned array held a raw Promise object rather than the resolved value. Callers would see { status: Promise { <pending> } } instead of useful rate-limit data. The function is now async and properly awaits each call.

Bug 2 - Missing SSR guard causes ReferenceError in Next.js

The fallback localStorage.getItem(...) call inside checkRateLimit() had no typeof localStorage !== 'undefined' guard. On server-side renders this throws ReferenceError: localStorage is not defined, crashing the Next.js middleware or any server component that imports this module. A guard and safe default return value have been added.

The same guard was added to getAllRateLimits() for consistency.

Files Changed

  • src/lib/rateLimiter.js

Testing

  • Call getAllRateLimits() - it should now return an array of resolved objects, not Promises.
    • Render a page server-side - no ReferenceError should be thrown.

@vercel

vercel Bot commented Apr 30, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the mericcintosun Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant