Add multi-Redis support and production hardening#2
Open
c-stoeckl wants to merge 3 commits intoupstash:masterfrom
Open
Add multi-Redis support and production hardening#2c-stoeckl wants to merge 3 commits intoupstash:masterfrom
c-stoeckl wants to merge 3 commits intoupstash:masterfrom
Conversation
Introduced a StorageAdapter interface supporting both Upstash Redis and standard open-source Redis. Users can now bring their own self-hosted Redis via REDIS_URL or continue using Upstash.
- Add connection error handling with retry logic (maxRetriesPerRequest: 3) - Add universal rate limiting for standard Redis via rate-limiter-flexible - Add ping() health check method to StorageAdapter interface - Use modern SET...EX instead of deprecated SETEX command - Fix edge case where ttlSeconds=0 was treated as falsy - Expose Redis client for rate limiting compatibility - Update README with both Upstash and standard Redis options Standard Redis users now have the same 60 req/min rate limiting protection as Upstash users. Both adapters include health checks for connection verification. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fix rate-limiter-flexible error handling (throws RateLimiterRes, not Error) - Add try/catch around storage operations for clean 500 errors - Add REDIS_TLS_INSECURE option for self-signed TLS certificates - Update documentation with new TLS option Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
143cd07 to
f9711ae
Compare
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
This PR adds support for using standard Redis servers alongside Upstash Redis, along with several production hardening improvements:
node-redisrate-limiter-flexible(throwsRateLimiterResobjects, notErrorinstances)REDIS_TLS_INSECUREoption for self-signed certificates in private deploymentsChanges
api/index.ts- Fixed rate limit error detection, added try/catch for storage operationssrc/storage/index.ts- New storage adapter factorysrc/storage/types.ts- Storage adapter interface definitionssrc/storage/redis.ts- Standard Redis adapter with TLS supportsrc/storage/upstash.ts- Upstash Redis adapter.env.example- Documented new configuration optionsREADME.md- Updated self-hosting documentationMotivation
When self-hosting memo with a standard Redis server (common in private deployments), the existing Upstash-only implementation required workarounds. This PR enables native support for standard Redis servers while maintaining full backward compatibility with Upstash.
The rate limiter fix addresses an issue where rate limit responses were not being properly detected, causing 500 errors instead of proper 429 responses.
Test Plan