Skip to content

Commit

Permalink
fix: Rate limiting can fail when using Parse Server option `rateLimit…
Browse files Browse the repository at this point in the history
….redisUrl` with clusters (parse-community#8632)
  • Loading branch information
dblythy authored Mar 24, 2024
1 parent cfcb943 commit c277739
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,19 +531,17 @@ export const addRateLimit = (route, config, cloud) => {
const redisStore = {
connectionPromise: Promise.resolve(),
store: null,
connected: false,
};
if (route.redisUrl) {
const client = createClient({
url: route.redisUrl,
});
redisStore.connectionPromise = async () => {
if (redisStore.connected) {
if (client.isOpen) {
return;
}
try {
await client.connect();
redisStore.connected = true;
} catch (e) {
const log = config?.loggerController || defaultLogger;
log.error(`Could not connect to redisURL in rate limit: ${e}`);
Expand Down

0 comments on commit c277739

Please sign in to comment.