fix(rateLimiter): await async checkRateLimit in getAllRateLimits + ad…#82
Open
Div1912 wants to merge 1 commit into
Open
Conversation
|
Someone is attempting to deploy a commit to the mericcintosun Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two bugs fixed in
src/lib/rateLimiter.js:Bug 1 - Unawaited async call in
getAllRateLimits()getAllRateLimits()calledcheckRateLimit(walletAddress)- an async function - withoutawait. This meant eachstatusfield in the returned array held a rawPromiseobject rather than the resolved value. Callers would see{ status: Promise { <pending> } }instead of useful rate-limit data. The function is nowasyncand properlyawaits each call.Bug 2 - Missing SSR guard causes
ReferenceErrorin Next.jsThe fallback
localStorage.getItem(...)call insidecheckRateLimit()had notypeof localStorage !== 'undefined'guard. On server-side renders this throwsReferenceError: 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.jsTesting
getAllRateLimits()- it should now return an array of resolved objects, not Promises.ReferenceErrorshould be thrown.