0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-05 08:02:42 +00:00

On patch failure, compare client and server text bytewise

This commit is contained in:
Trevor Buckner
2025-07-10 11:12:42 -04:00
parent 68460447dc
commit c5805af935
2 changed files with 39 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ import { nanoid } from 'nanoid';
import {makePatches, applyPatches, stringifyPatches, parsePatch} from '@sanity/diff-match-patch';
import { md5 } from 'hash-wasm';
import { splitTextStyleAndMetadata,
brewSnippetsToJSON } from '../shared/helpers.js';
brewSnippetsToJSON, debugTextMismatch } from '../shared/helpers.js';
import checkClientVersion from './middleware/check-client-version.js';
@@ -364,6 +364,7 @@ const api = {
const patchedResult = applyPatches(patches, brewFromServer.text)[0];
// brew.text = applyPatches(patches, brewFromServer.text)[0];
} catch (err) {
debugTextMismatch(brewFromClient.text, brewFromServer.text, `edit/${brewFromClient.editId}`);
console.error('Failed to apply patches:', {
patches : brewFromClient.patches,
brewId : brew.editId || 'unknown',