fix: Rate limiting can fail when using Parse Server option rateLimit.redisUrl with clusters (#8632)

This commit is contained in:
Daniel
2024-03-24 12:17:21 +11:00
committed by GitHub
parent cfcb943ba5
commit c277739623

View File

@@ -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}`);