A tab closed mid-sentence. When it opened again the paragraph was gone, and the little "Syncing…" pill had been lying for the last two minutes.
That pattern is common enough that I now look for it before reading any offline-first code: the thing that decides what to save lives in memory, and memory is the one store a closed tab does not keep. An outbox is the fix, and it is smaller than a sync engine.
Here is the whole design: one IndexedDB store, one idempotency key per mutation, one flush loop, and a server-side dedupe table that makes a double flush harmless.
Why "sync" is the wrong word
A sync engine implies reconciliation: vector clocks, merge functions, conflict UI. Most client documents do not need that. They need a queue that outlives the tab.
Three failure modes cover almost every bug I have seen in this area:
The write depends on a component. The save runs in an effect that unmounts, or behind a debounce that never fires because the tab died first.
The retry is not idempotent.…