Invental/Review lessons/Client state that goes stale

Client state that goes stale

A full resync is not a cheap retry

A “reset sync” that clears clocks is a full re-download, not a cheap retry: trigger it only from a state that proves sync is stuck, never from mount effects, timers or diagnostics, and never twice at once.

01 · Before and afterThe pattern

Gate a destructive recovery on observed state and a single in-flight guard.

TypeScript
let resetting: Promise<void> | null = null;
syncState$.subscribe(s => {
  if (s.status !== 'stuck' || resetting) return;   // before: setTimeout(reset, 0 / 5000 / 15000) on every mount
  resetting = engine.forceFullResync({ timeoutMs: 30_000 })
    .catch(err => log.warn('reset failed', err))
    .finally(() => { resetting = null; });
});

02 · Run it on your appThe check

Can you list every place your app forces a full resync, and does each one fire only when sync is provably stuck?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.