Unverified Commit 327bd946 authored by Brian Ewins's avatar Brian Ewins Committed by GitHub

examples: cache-handler example should reconnect to redis after errors (#68221)

Co-authored-by: 's avatarArseny <132773930+better-salmon@users.noreply.github.com>
Co-authored-by: 's avatarLee Robinson <me@leerob.io>
parent 162342c8
...@@ -16,8 +16,12 @@ CacheHandler.onCreation(async () => { ...@@ -16,8 +16,12 @@ CacheHandler.onCreation(async () => {
}); });
// Redis won't work without error handling. // Redis won't work without error handling.
// NB do not throw exceptions in the redis error listener,
// because it will prevent reconnection after a socket exception.
client.on("error", (e) => { client.on("error", (e) => {
throw e; if (typeof process.env.NEXT_PRIVATE_DEBUG_CACHE !== "undefined") {
console.warn("Redis error", e);
}
}); });
} catch (error) { } catch (error) {
console.warn("Failed to create Redis client:", error); console.warn("Failed to create Redis client:", error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment