From 986c36b677b10447e1db4b8e6ac1519cb35fda35 Mon Sep 17 00:00:00 2001 From: Batmanisko Date: Wed, 20 May 2026 18:47:47 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20oprava=20updateData=20v=20Redis=20storag?= =?UTF-8?q?e=20(node-redis=20v5=20nem=C3=A1=20executeIsolated)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/storage/redis.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/src/storage/redis.ts b/server/src/storage/redis.ts index ac20287..78ff76c 100644 --- a/server/src/storage/redis.ts +++ b/server/src/storage/redis.ts @@ -32,18 +32,23 @@ export default class RedisStorage implements StorageInterface { } async updateData(key: string, mutator: (current: Type | undefined) => Type): Promise { - return (client as any).executeIsolated(async (c: any) => { + // node-redis v5 nemá executeIsolated — pro WATCH/MULTI potřebujeme dedikované spojení + const c = client.duplicate(); + await c.connect(); + try { for (let attempt = 0; attempt < 10; attempt++) { await c.watch(key); const current = await c.json.get(key, { path: '.' }) as Type | undefined; const next = mutator(current); const multi = c.multi(); - multi.json.set(key, '.', next); + multi.json.set(key, '.', next as any); const result = await multi.exec(); if (result !== null) return next; } throw new Error(`updateData: optimistic lock failed after 10 retries for key: ${key}`); - }); + } finally { + await c.disconnect(); + } } async healthCheck(): Promise {