Skip to content

fix(#215)#246

Open
anshul23102 wants to merge 1 commit into
Coder-s-OG-s:mainfrom
anshul23102:fix/215-memory-backend-warning
Open

fix(#215)#246
anshul23102 wants to merge 1 commit into
Coder-s-OG-s:mainfrom
anshul23102:fix/215-memory-backend-warning

Conversation

@anshul23102
Copy link
Copy Markdown
Contributor

@anshul23102 anshul23102 commented Jun 1, 2026

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

  • Bug fix

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

  • `src/lib/cache.ts` (or equivalent): added a `console.error` log in production when `MemoryBackend` is selected as fallback, and exported `isSharedCacheAvailable` flag so route handlers and health checks can surface the misconfiguration.

Testing

  • Starting the server without `REDIS_URL` set in production logs the warning
  • `isSharedCacheAvailable` returns `false` when MemoryBackend is active
  • Existing CI checks pass

Checklist

  • No hardcoded secrets or credentials
  • Single focused change
  • No merge conflicts with main

… 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.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jun 1, 2026

@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.

@github-actions github-actions Bot mentioned this pull request Jun 1, 2026
7 tasks
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

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.

@github-actions github-actions Bot mentioned this pull request Jun 1, 2026
9 tasks
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] MemoryBackend silently selected when Redis is unconfigured, making all rate limiting per-Lambda-invocation and effectively disabled in production

1 participant