mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-12 06:27:10 +03:00
Don't fallback to db when too many redis connections
This commit is contained in:
@@ -46,6 +46,8 @@ const writeResponseTime: number[] = [];
|
||||
let lastResponseTimeLimit = 0;
|
||||
const maxStoredTimes = 200;
|
||||
|
||||
export class TooManyActiveConnectionsError extends Error {}
|
||||
|
||||
export let connectionPromise = Promise.resolve();
|
||||
|
||||
if (config.redis?.enabled) {
|
||||
@@ -61,7 +63,7 @@ if (config.redis?.enabled) {
|
||||
const getRead = readClient?.get?.bind(readClient);
|
||||
exportClient.get = (key) => new Promise((resolve, reject) => {
|
||||
if (config.redis.maxConnections && activeRequests > config.redis.maxConnections) {
|
||||
reject("Too many active requests in general");
|
||||
reject(new TooManyActiveConnectionsError("Too many active requests in general"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user