WAL state machine: recordings marked corrupted stay pending in UI but are never retried
Describe the bug
A phone WAL that flips from WalStatus.miss to WalStatus.corrupted can become a permanent zombie recording: it still appears in the app as a pending recording, but the background uploader no longer retries it.
This is a separate issue from live reconnect gaps. It is a WAL state-machine mismatch between the UI and the retry logic.
To Reproduce
- Create a phone-side WAL in
WalStatus.miss(for example by causing live streaming to miss audio and save a local WAL). - Let the app attempt upload.
- Hit one of the pre-upload
corruptedtransitions inLocalWalSyncImpl, for example:filePath == null- resolved file path is null
- file missing on disk
- unexpected exception while preparing the file for upload
- Refresh the sync UI / reopen the app.
Current behavior
- The recording still appears in the UI as pending.
deleteAllPendingWals()also treats it as pending.- But background auto-upload and normal retry paths only select
WalStatus.miss. - Result: the WAL is stranded forever unless the user manually deletes it or some other code mutates it back.
Expected behavior One of these should be true, consistently:
- recoverable file-access errors should stay retryable and continue uploading automatically, or
- the app should distinguish fatal/unrecoverable corruption from retryable transient errors, and only show true retryable items as pending.
Right now it does neither.
Code-backed root cause
-
UI pending list includes
corrupted.app/lib/providers/sync_provider.dart:41-42List<Wal> get pendingWals => _allWals.where((w) => w.status == WalStatus.miss || w.status == WalStatus.corrupted || w.isSyncing).toList(); -
Delete-all-pending also includes
corrupted.app/lib/services/wals/local_wal_sync.dart:470-472final pendingWals = _wals.where((w) => w.status == WalStatus.miss || w.status == WalStatus.corrupted).toList(); -
But
syncAll()only retriesmiss.app/lib/services/wals/local_wal_sync.dart:504var wals = _wals.where((w) => w.status == WalStatus.miss && w.storage == WalStorage.disk).toList(); -
Auto-upload also only picks
miss.app/lib/providers/sync_provider.dart:158-160final phoneWals = _allWals .where((w) => w.status == WalStatus.miss && (w.storage == WalStorage.disk || w.storage == WalStorage.mem)) .toList(); -
Startup orphan recovery also only picks
miss.app/lib/services/wals/local_wal_sync.dart:435-439.where((w) => w.status == WalStatus.miss && w.storage == WalStorage.disk && w.conversationId != null && w.retryCount < 3) -
corruptedis assigned in pre-upload file preparation.app/lib/services/wals/local_wal_sync.dart:551-588filePath == nullfullPath == null!file.existsSync()- broad
catch (e)while preparing file access
That means a WAL can move into a state that the user still sees as pending, but no retry path ever touches again.
Important distinction
The upload-batch network/server failure path does not directly cause this bug. The batch upload catch keeps WALs retryable. This issue is specifically about the pre-upload corrupted transitions and the fact that corrupted is then excluded from retry paths.
Suggested fixes
- Best fix: split
corruptedinto at least two states:fatalMissingOrInvalidretryableFileAccessError
- Or, before retry selection, revalidate
corruptedWALs and flip them back tomisswhen the file is actually present and readable. - Or, include recoverable
corruptedWALs in retry queues with bounded backoff. - If some
corruptedWALs are truly unrecoverable, give the UI a distinct non-pending state or a cleardelete/ignoreaction instead of leaving them mixed into Pending forever.
Related issues
- #6977 — stale BLE live-stream path can create missing-middle-audio gaps
- #6171 — reconnect/manual-recovery UX issue
- #5733 — umbrella capture-loss issue
user ID (can we access the user info to validate the bug?): Not included here.
Smartphone + device (please complete the following information):
- Device: phone-side WAL path; not tied to one hardware model
- OS: not pinned here
- Browser: N/A
- App Version: not pinned here
- Device version: N/A
Additional context This is the classic "pending forever" / zombie recording symptom: visible to the user, counted as pending, but never retried by background sync.
Update after more user testing and checking john-gitdev/omi:retry-sync:
For recordings that retry on app reopen, I no longer think corrupted is the primary state. Auto-upload and LocalWalSyncImpl.syncAll() only select WalStatus.miss, so a WAL that retries on reopen is almost certainly still miss.
Current best root-cause read for the retrying/phantom pending files:
-
local_wal_sync.dartbatches overlap by one file. Withsteps = 3, current code setsleft = right - stepsand then loopsj <= right, so each batch contains 4 files and adjacent batches share one WAL. Theretry-syncbranch changes this toleft = right - steps + 1, which matches the intended batch size. -
Upload result handling is batch-level, not per-file. If the server returns a partial failure, the app keeps every WAL in that local batch as
miss, even if only one file/segment was the real failure. With the overlap bug, one bad file can repeatedly poison neighboring good files and make them appear as phantom pending/retrying recordings. -
Backend Opus decode currently aborts a whole file on the first bad frame decode. In
backend/routers/sync.py,decode_opus_file_to_wav()catches a decode exception andbreaks. Theretry-syncbranch changes that tocontinue, so a single bad frame does not kill the rest of the file. That is consistent with user reports of files existing and retrying, but not getting processed.
So I would describe the root cause for the retrying miss case as:
A single malformed/undecodable audio frame or bad file can cause server-side partial failure, and the app maps that failure back to an overlapping batch rather than the specific failed file/segment. This strands healthy WALs in
missand causes repeated retries.
This issue is still valid, but it covers a different symptom: Pending rows that are corrupted and therefore do not retry. The confusing UI state comes from pendingWals = miss || corrupted || isSyncing, while missing-duration and retry paths only count miss.