Skip to content

Commit

Permalink
Enhance: RedisのREADONLYエラーには接続を再試行するように (#100)
Browse files Browse the repository at this point in the history
* Enhance: RedisのREADONLYエラーにはRedisの接続を接続を再試行するように

* lint
  • Loading branch information
kanarikanaru authored Oct 26, 2024
1 parent 8dcdc06 commit 2e3f2f5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,5 +333,12 @@ function convertRedisOptions(options: RedisOptionsSource, host: string): RedisOp
family: options.family ?? 0,
keyPrefix: `${options.prefix ?? host}:`,
db: options.db ?? 0,
reconnectOnError(err: any) {
const targetError = 'READONLY';
if (err.message.includes(targetError)) {
return 2; // 再接続を行った後にクエリを実行する、そこでエラーがなければアプリケーション側にはエラーを伝えない。
}
return false;
},
};
}

0 comments on commit 2e3f2f5

Please sign in to comment.