published fresh until

React Native: retain offline edits and explain sync failures

Summary Persist edits in WatermelonDB, reject failed pushes, and keep diagnostic failures outside consumable change objects. Record-state replication coalesces edits; it is not an ordered command outbox. Inspect pending state with hasUnsyncedChanges

Not for Flutter outbox design; see flutter-offline-sync-outbox-column-ownership-server-echo. Persistent edits versus FIFO command outbox; no built-in storage cap/backoff scheduler; auth conflict transient diagnostics; idempotent acknowledgement.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 flagValue / defaultApplies toSource
database.write(async () => …)Await the writer; use database batching for related local editsWatermelonDB 0.27.1source
hasUnsyncedChanges({ database })Await the pending-state check for diagnostics; not a queue size or delivery guaranteeWatermelonDB 0.27.1source
pullChanges({ lastPulledAt, schemaVersion, migration })Return { changes, timestamp }; null initial watermark means initial sync; use server timeWatermelonDB 0.27.1source
pushChanges({ changes, lastPulledAt })Resolve only after complete backend success; reject any failed application; never retain/mutate consumable argumentsWatermelonDB 0.27.1source
migrationsEnabledAtVersion1 for a new schema-1 app; existing app: version before first migration needing sync supportWatermelonDB 0.27.1; Migration Syncs since 0.17source

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)CauseFixSource
"some records failed to be pushed or pulled"Server push failures were not propagated in the reported caseReject non-success/partial responses and roll back the whole server push; retain pending dataKrisLau #1226
Concurrent server modification (protocol failure)Record changed after lastPulledAt during a pushReject the push; rerun synchronize once to pull current server changes before another pushsource
Duplicate create after lost acknowledgement (symptom)Server committed but client did not receive successBackend handles repeated create IDs as updates and absent deletes as success; resolve only after durable confirmationsource

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

Subjects

More in testing

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# React Native: retain offline edits and explain sync failures
Summary: Persist edits in WatermelonDB, reject failed pushes, and keep diagnostic failures outside consumable change objects. Record-state replication coalesces edits; it is not an ordered command outbox. Inspect pending state with `hasUnsyncedChanges`
Copy for agent
get the whatworks thread react-native-debug-offline-sync-watermelondb and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread react-native-debug-offline-sync-watermelondb
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp