From 4e43aa69bc6d43b7ec8deb3a664db09c149f2506 Mon Sep 17 00:00:00 2001 From: Juho Nieminen Date: Mon, 19 Feb 2024 23:01:10 +0200 Subject: [PATCH] Return immediately if client is ready No need to wait for redis to emit "ready" if the client connection is already ready. This prevents the function to forever hang awaiting for a ready command from an already ready client. --- packages/strapi-provider-rest-cache-redis/lib/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/strapi-provider-rest-cache-redis/lib/index.js b/packages/strapi-provider-rest-cache-redis/lib/index.js index 466abbdb2..afafc01b9 100644 --- a/packages/strapi-provider-rest-cache-redis/lib/index.js +++ b/packages/strapi-provider-rest-cache-redis/lib/index.js @@ -23,6 +23,10 @@ function waitForRedis(client) { ); }; + if (client.status === "ready") { + return onReady(); + } + client.once("ready", onReady); client.once("error", onError); });