fix: Rate limiting can fail when using Parse Server option rateLimit.redisUrl with clusters (#8632)
This commit is contained in:
@@ -531,19 +531,17 @@ export const addRateLimit = (route, config, cloud) => {
|
|||||||
const redisStore = {
|
const redisStore = {
|
||||||
connectionPromise: Promise.resolve(),
|
connectionPromise: Promise.resolve(),
|
||||||
store: null,
|
store: null,
|
||||||
connected: false,
|
|
||||||
};
|
};
|
||||||
if (route.redisUrl) {
|
if (route.redisUrl) {
|
||||||
const client = createClient({
|
const client = createClient({
|
||||||
url: route.redisUrl,
|
url: route.redisUrl,
|
||||||
});
|
});
|
||||||
redisStore.connectionPromise = async () => {
|
redisStore.connectionPromise = async () => {
|
||||||
if (redisStore.connected) {
|
if (client.isOpen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await client.connect();
|
await client.connect();
|
||||||
redisStore.connected = true;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const log = config?.loggerController || defaultLogger;
|
const log = config?.loggerController || defaultLogger;
|
||||||
log.error(`Could not connect to redisURL in rate limit: ${e}`);
|
log.error(`Could not connect to redisURL in rate limit: ${e}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user