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 {