Skip to content

Commit

Permalink
fix: Stop crashing when redis is offline and ignoreErrors on cache op…
Browse files Browse the repository at this point in the history
…tions is set
  • Loading branch information
mesinger committed Mar 3, 2022
1 parent f3cfdd2 commit f50c4ab
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cache/RedisQueryResultCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ export class RedisQueryResultCache implements QueryResultCache {
...cacheOptions?.options,
legacyMode: true
});
this.client.on("error", (err: any) => {
if (typeof this.connection.options.cache === "object" && this.connection.options.cache.ignoreErrors) {
this.connection.logger.log("warn", "redis call failed");
} else {
throw err;
}
});
if ("connect" in this.client) {
await this.client.connect();
}
Expand Down

0 comments on commit f50c4ab

Please sign in to comment.