fix(sync): don't delete a local row when the server can't send its copy (#1650)

* fix(sync): don't delete a local row when the server can't send its copy

A push conflict on a live record whose server row failed to serialize
came back as row: null, deleted: false, and the desktop treated that as
a delete. The server now rejects that op as unavailable, the desktop
never deletes on a conflict without a row, and serialization failures
are logged.

* fix(sync): retry temporarily unavailable records
This commit is contained in:
ZacharyZcR authored and GitHub committed 2026-10-15 14:59:59 +08:00
1 parent bc74fba3f5
commit 071711dafc
4 files changed
+172 -6

No files matched your search

+12 -1
View File
@@ -134,12 +134,23 @@ export async function applyPush(
const record = await getRecord(userId, op.entityType, op.syncId);
const currentRevision = record?.revision ?? 0;
if (op.baseRevision !== currentRevision) {
const row = record?.deleted ? null : (wire.get(key) ?? null);
// A live record with no row failed to serialize; a conflict without a
// row would read as a delete on the desktop.
if (record && !record.deleted && !row) {
results.set(key, {
...base,
status: "rejected",
reason: "unavailable",
});
continue;
}
results.set(key, {
...base,
status: "conflict",
revision: currentRevision,
deleted: !!record?.deleted,
row: record?.deleted ? null : (wire.get(key) ?? null),
row,
});
continue;
}