[Diagnostic error: [Sync] Server wants client to create record on Syncronizacion
Hello
I am getting the following error when synchronizing:
ERROR [Diagnostic error: [Sync] Server wants client to create record gastos#67c9b0f39d9b6bfadf630d1b, but it already exists locally. This may suggest last sync partially executed, and then failed; or it could be a serious bug. Will update existing record instead.]
the flow is as follows.
a record is created from the application, it is updated correctly in the backend, with the synchronization, but something happens that then tries to create in the device base the same record.
my kind of synchronization I did it guided by the documentation:
class class SyncService {
static async pullChanges({lastPulledAt, schemaVersion, migration}) {
const urlParams = `lastPulledAt=${lastPulledAt}&schema_version=${schemaVersion}&migration=${encodeURIComponent(
JSON.stringify(migration),
)}`;
try {
const response = await MyApi.get(
`/watermelon-sync/pull?${urlParams}`,
);
return {changes: deserializeChanges, timestamp};
} catch (error) {
console.error('Error during pullChanges:', error);
}
}
static async pushChanges({changes, lastPulledAt}) {
.. logic for push
}
static async sync() {
await synchronize({
database,
pullChanges: SyncService.pullChanges,
pushChanges: SyncService.pushChanges,
});
}
} export default SyncService;
I am wrapping the app with a SyncWrapper which calls this service and executes every 10 seconds.
the SYnc is correct, but I'm receiving this error.
please send me your comments
I have the same problem. @fmoraless Were you able to find a solution?