fix: oprava updateData v Redis storage (node-redis v5 nemá executeIsolated)
CI / Generate TypeScript types (push) Successful in 11s
CI / Server unit tests (push) Successful in 21s
CI / Build server (push) Successful in 24s
CI / Build client (push) Successful in 33s
CI / Playwright E2E tests (push) Successful in 1m16s
CI / Build and push Docker image (push) Has been skipped
CI / Notify (push) Successful in 2s

This commit is contained in:
2026-05-20 18:47:47 +02:00
parent 67abbf19b5
commit 986c36b677
+8 -3
View File
@@ -32,18 +32,23 @@ export default class RedisStorage implements StorageInterface {
} }
async updateData<Type>(key: string, mutator: (current: Type | undefined) => Type): Promise<Type> { async updateData<Type>(key: string, mutator: (current: Type | undefined) => Type): Promise<Type> {
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++) { for (let attempt = 0; attempt < 10; attempt++) {
await c.watch(key); await c.watch(key);
const current = await c.json.get(key, { path: '.' }) as Type | undefined; const current = await c.json.get(key, { path: '.' }) as Type | undefined;
const next = mutator(current); const next = mutator(current);
const multi = c.multi(); const multi = c.multi();
multi.json.set(key, '.', next); multi.json.set(key, '.', next as any);
const result = await multi.exec(); const result = await multi.exec();
if (result !== null) return next; if (result !== null) return next;
} }
throw new Error(`updateData: optimistic lock failed after 10 retries for key: ${key}`); throw new Error(`updateData: optimistic lock failed after 10 retries for key: ${key}`);
}); } finally {
await c.disconnect();
}
} }
async healthCheck(): Promise<boolean> { async healthCheck(): Promise<boolean> {