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

+8 -1
View File
@@ -13,6 +13,7 @@ import { createCurrentRepositoryContext } from "../database/repositories/factory
import { DataCrypto } from "../utils/data-crypto.js";
import { SystemCrypto } from "../utils/system-crypto.js";
import { DatabaseSaveTrigger } from "../utils/database-save-trigger.js";
import { syncLogger } from "../utils/logger.js";
import {
getEntity,
type RegisteredSyncEntity,
@@ -229,7 +230,13 @@ export async function loadWireRows(
);
const wire = toWire(entity, serialized, syncId);
rows.set(syncId, { syncId, wire, hash: hashWire(entity, wire, key) });
} catch {
} catch (error) {
syncLogger.warn("Could not serialize a sync row", {
operation: "sync_serialize",
entityType: entity.type,
syncId,
error: error instanceof Error ? error.message : String(error),
});
failed.add(syncId);
}
}