fix(#215)#246
Open
anshul23102 wants to merge 1 commit into
Open
Conversation
… fallback Closes Coder-s-OG-s#215 pickDefaultBackend() fell back to MemoryBackend silently when neither KV_REST_API_URL/KV_REST_API_TOKEN nor REDIS_URL were set. In a serverless deployment each invocation runs in its own isolated process, so the in-memory counter resets on every invocation and rate limits are never enforced across concurrent requests. Added a console.error in production when the MemoryBackend path is reached, naming the missing env vars explicitly so the misconfiguration is visible in logs on first deploy. Also exported isSharedCacheAvailable (a boolean resolved at module load) so callers such as health-check endpoints and admin dashboards can surface the state without re-checking environment variables.
Contributor
|
@anshul23102 is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey @anshul23102 You have 4 open PRs right now. The limit is 3 at a time. Please get your existing PRs merged or closed before opening new ones:
This PR will remain open but won't be reviewed until you're under the limit. See our Contributing Guidelines for details. |
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
Logs a production-level error when the rate limiter silently falls back to `MemoryBackend`, and exports `isSharedCacheAvailable` so callers can detect the degraded state.
Related Issue
Closes #215
Type of Change
Root Cause
`pickDefaultBackend` fell back to `MemoryBackend` with no warning when Redis was unconfigured. In serverless deployments each Lambda invocation has its own isolated process memory, so rate limit counters are never shared across invocations. The limiter appears to work but enforces nothing at scale.
What Changed
Testing
Checklist