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
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:
@@ -32,18 +32,23 @@ export default class RedisStorage implements StorageInterface {
|
||||
}
|
||||
|
||||
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++) {
|
||||
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<boolean> {
|
||||
|
||||
Reference in New Issue
Block a user