mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-19 14:17:20 +02:00
chore(deps): upgrade dependencies and remove production vulnerabilities
This commit is contained in:
1 parent
9435a99b6c
commit
fd0dd0adbd
29 files changed
+5220
-21129
No files matched your search
@@ -155,12 +155,12 @@ function ensureRedisGateClient(): Promise<RedisClientType | null> {
|
||||
socket: {
|
||||
host: config.REDIS_HOSTNAME,
|
||||
port: config.REDIS_PORT,
|
||||
reconnectStrategy: () => false as any,
|
||||
reconnectStrategy: false,
|
||||
},
|
||||
}) as RedisClientType;
|
||||
c.on("error", () => {
|
||||
redisGateDisabled = true;
|
||||
c.disconnect().catch(() => {});
|
||||
if (c.isOpen) c.destroy();
|
||||
redisGateReady = null;
|
||||
});
|
||||
await c.connect();
|
||||
|
||||
@@ -13,7 +13,7 @@ export async function cacheCommand<T>(command: Promise<T>, client: ReturnType<ty
|
||||
timer = setTimeout(() => {
|
||||
retryAt = Date.now() + 30_000;
|
||||
if (connection === client) connection = undefined;
|
||||
if (client.isOpen) void client.disconnect().catch(() => {});
|
||||
if (client.isOpen) client.destroy();
|
||||
reject(new Error("cache_command_timeout"));
|
||||
}, timeoutMs);
|
||||
})]);
|
||||
@@ -30,7 +30,7 @@ export async function cacheRedis() {
|
||||
} });
|
||||
client.on("error", () => {});
|
||||
try { await cacheCommand(client.connect(), client, 500); connection = client; return client; }
|
||||
catch { retryAt = Date.now() + 30_000; if (client.isOpen) await client.disconnect().catch(() => {}); return undefined; }
|
||||
catch { retryAt = Date.now() + 30_000; if (client.isOpen) client.destroy(); return undefined; }
|
||||
finally { connecting = undefined; }
|
||||
})();
|
||||
return connecting;
|
||||
@@ -79,5 +79,5 @@ export async function closeCacheRedis() {
|
||||
const current = connection;
|
||||
connection = undefined;
|
||||
retryAt = 0;
|
||||
if (current?.isOpen) await current.disconnect();
|
||||
if (current?.isOpen) current.destroy();
|
||||
}
|
||||
+1
-1
@@ -74,7 +74,7 @@ function getRedis(): RedisClientType | null {
|
||||
const c = redisClient;
|
||||
redisClient = null;
|
||||
if (c?.isOpen) {
|
||||
c.disconnect().catch(() => {});
|
||||
c.destroy();
|
||||
}
|
||||
});
|
||||
redisClient.connect().catch(() => {
|
||||
|
||||
@@ -30,7 +30,10 @@ async function redisDeadline<T>(work: Promise<T>, redis: RedisClientType): Promi
|
||||
return await Promise.race([work, new Promise<never>((_resolve, reject) => {
|
||||
timer = setTimeout(() => {
|
||||
reject(new Error("performance_monitoring_timeout"));
|
||||
if (redis.isOpen) void redis.disconnect().then(() => client === redis ? redis.connect() : undefined).catch(() => {});
|
||||
if (redis.isOpen) {
|
||||
redis.destroy();
|
||||
if (client === redis) void redis.connect().catch(() => {});
|
||||
}
|
||||
}, 2000); timer.unref();
|
||||
})]);
|
||||
} finally { clearTimeout(timer); }
|
||||
@@ -75,7 +78,7 @@ export async function socketSnapshot() {
|
||||
export function startPerformanceMonitoring(service: Service, workers: () => unknown = () => null) {
|
||||
if (stop) return stop;
|
||||
const redis = createClient({ disableOfflineQueue: true, socket: { host: config.REDIS_HOSTNAME,
|
||||
port: config.REDIS_PORT, connectTimeout: 2000, reconnectStrategy: retries => Math.min(5000, 250 * (retries + 1)) } }) as RedisClientType;
|
||||
port: config.REDIS_PORT, connectTimeout: 2000, reconnectStrategy: (retries: number) => Math.min(5000, 250 * (retries + 1)) } }) as RedisClientType;
|
||||
client = redis;
|
||||
redis.on("error", () => {});
|
||||
void redis.connect().catch(() => {});
|
||||
@@ -135,7 +138,7 @@ export function startPerformanceMonitoring(service: Service, workers: () => unkn
|
||||
void flush();
|
||||
stop = async () => {
|
||||
stopped = true; clearInterval(timer); loop.disable();
|
||||
if (redis.isOpen) await redis.disconnect();
|
||||
if (redis.isOpen) redis.destroy();
|
||||
client = undefined; stop = undefined; flushNow = undefined; reports.clear();
|
||||
};
|
||||
return stop;
|
||||
|
||||
Reference in new issue
Block a user