What this thread does
Do first: compare hasUnsyncedChanges({ database }) before and after an offline edit and process restart.
Short answer
As of November 2026, use the WatermelonDB 0.27.1 release and 0.27.1 sync contract. Await a persistent writer before presenting the durable edit; only a successful complete server acknowledgement may clear its pending state.
Choose / don't choose
- Record sync: choose for editable records with per-column reconciliation; don't use it to preserve the historical order of every command (change tracking).
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
database.write(async () => …) | Await the writer; use database batching for related local edits | WatermelonDB 0.27.1 | source |
hasUnsyncedChanges({ database }) | Await the pending-state check for diagnostics; not a queue size or delivery guarantee | WatermelonDB 0.27.1 | source |
pullChanges({ lastPulledAt, schemaVersion, migration }) | Return { changes, timestamp }; null initial watermark means initial sync; use server time | WatermelonDB 0.27.1 | source |
pushChanges({ changes, lastPulledAt }) | Resolve only after complete backend success; reject any failed application; never retain/mutate consumable arguments | WatermelonDB 0.27.1 | source |
migrationsEnabledAtVersion | 1 for a new schema-1 app; existing app: version before first migration needing sync support | WatermelonDB 0.27.1; Migration Syncs since 0.17 | source |
Order of operations
1. Persist the edit in database.write; render from the observed durable row. Keep _status and _changed under Watermelon control (implementation). 2. One sync owner serializes reconnect/resume/write triggers; debounce local writes. It advises one retry after failure, so at most two immediate synchronize calls in that wrapper, not infinite retries (frontend lifecycle). 3. Pull remote changes before collecting local changes to push. Send stable record IDs and lastPulledAt; require all-or-nothing server application. Do not use record IDs as arbitrary command idempotency IDs (backend rules). 4. Application diagnostic policy: persist sanitized HTTP status/error category, affected record IDs, attempt time and retry action separately from consumable changes. Classify network/temporary-server failures, reauthentication needs and pull-before-push conflicts. Do not label every exception a network failure. For an HTTP backend, 401 means invalid/missing authentication; 409 denotes a resource-state conflict, do not assume a universal conflict code (HTTP semantics). 5. Surface the second failure and pending count in a diagnostic UI. Inspect the same row offline after restart, then on another device after sync. Never reset the local database while synchronization runs.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
| "some records failed to be pushed or pulled" | Server push failures were not propagated in the reported case | Reject non-success/partial responses and roll back the whole server push; retain pending data | KrisLau #1226 |
| Concurrent server modification (protocol failure) | Record changed after lastPulledAt during a push | Reject the push; rerun synchronize once to pull current server changes before another push | source |
| Duplicate create after lost acknowledgement (symptom) | Server committed but client did not receive success | Backend handles repeated create IDs as updates and absent deletes as success; resolve only after durable confirmation | source |
Missing
- Choose application queue/storage limits without silently deleting unsynced edits.
- App-specific connectivity, reauthentication, numeric backoff and later retry policy remain to be implemented.
- Ordered operation replay requires a separate durable command-outbox contract; Watermelon record replication does not provide one.
Checked
2026-11-12; Sources read: linked release, writer, frontend, backend and implementation references, plus historical error-propagation issue. No mobile or sync commands executed.
Not for: Flutter outbox design; see flutter-offline-sync-outbox-column-ownership-server-echo.
Started from a post by @Nozbe, packaged by the editor. Original post