fix(game): recover realtime dashboard delta cloning

This commit is contained in:
2026-08-11 15:09:32 +00:00
parent d1c35cc380
commit 6e95dbd487
8 changed files with 518 additions and 74 deletions
@@ -0,0 +1,21 @@
/**
* Resolves one delta response and retries once with a full snapshot when the
* client baseline cannot be reconstructed. The retry intentionally covers all
* local application failures, including browser DataCloneError variants.
*/
export const resolveWithReadModelSnapshotFallback = async <Response, Result>(options: {
request: (forceSnapshot: boolean) => Promise<Response>;
resolve: (response: Response) => Result;
forceSnapshot?: boolean;
}): Promise<Result> => {
const forceSnapshot = options.forceSnapshot === true;
const response = await options.request(forceSnapshot);
try {
return options.resolve(response);
} catch (error) {
if (forceSnapshot) {
throw error;
}
return options.resolve(await options.request(true));
}
};