A tester handed us a phone and said the pending list was empty. It was not supposed to be. They had queued changes offline a minute earlier, then force-closed the app.
The queue had read its stored blob, failed to parse it, and returned an empty array. From the app's point of view that is the same as a fresh install. Worse, the next write replaced the bad bytes, so by the time we looked the evidence was gone. We spent an afternoon reconstructing what had been in there from server-side traces, and we still could not say with confidence whether anything was lost.
That is the part that stung. Not the corruption itself, since storage gets truncated, schemas change, people roll builds back. The problem was that our recovery path destroyed the only copy of the thing we needed to diagnose.
So in our open-source project offlinequeue the storage layer now has a fixed order on load.
Fetch the raw value. If it is falsy, return an empty array and stop, because a missing key is absence, not damage, and reporting it would train everyone to ignore the signal.
Otherwise decode it, and let decode answer with the operations it could recover plus an optional error: either the parse failure message, or a constant for the case where the JSON is valid but is not an array.
Only if there is an error, copy the original bytes aside under the same key with a quarantine suffix. Only after that write succeeds, call the onQuarantine callback with the key, the quarantine key and the error.
The ordering is the whole design. Reporting before the copy means the event hands someone a pointer to bytes that may not exist. Both real adapters take the same options, and the in-memory backend has no quarantine path at all, because there is nothing to preserve across a restart.
The app still starts empty in that case. We did not try to be clever about partial recovery. The difference is that empty now comes with a reason attached, and the broken payload is still on disk for the next support session.
A degraded start is acceptable. A degraded start that looks identical to a clean one is how you lose a week.
For teams running offline-first clients: do you keep quarantined payloads on the device, or ship them up with diagnostics? We have gone back and forth on it. The bytes can contain user data, and that changes the answer.