Menu

An outbox, not a sync engine: offline edits that survive a closed tab
📰

An outbox, not a sync engine: offline edits that survive a closed tab

DEV Community: database·Revercue·2 days ago
#sB5GEboG
#devtodatabase#devto#dev#outbox#server
Long article (1423 words) — no AI summary yet.
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.