mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
fix(offline): replay queued writes an interrupted flush left behind
A flush marks each row 'syncing' before it sends, and only ever picks up rows that are 'pending'. Kill the tab mid-request - the OS evicting a PWA does exactly this - and the row stays 'syncing' forever: it keeps counting towards the pending badge, but nothing ever retries it, fails it or shows it as a conflict. Anything queued behind it that depends on it later fails with 'unresolved temp id'. Stamp the row when it goes in flight and reclaim it on the next flush. The axios instance times out at 8s, so a minute is well past anything that could still be running, and the mutation id doubles as the idempotency key, so replaying a write the server already applied is answered from its cache.
This commit is contained in:
@@ -51,6 +51,13 @@ export interface QueuedMutation {
|
||||
conflictServer?: unknown;
|
||||
/** When the conflict was detected (for ordering / display). */
|
||||
conflictAt?: number;
|
||||
/**
|
||||
* When the row was marked 'syncing'. Only meaningful while it is — the flush
|
||||
* that set it clears the row on success or moves it off 'syncing' on failure.
|
||||
* A stamp that outlives its flush is how a killed tab is recognised on the
|
||||
* next one (see mutationQueue's STUCK_SYNCING_MS).
|
||||
*/
|
||||
syncingSince?: number;
|
||||
}
|
||||
|
||||
export interface SyncMeta {
|
||||
|
||||
Reference in New Issue
Block a user