macsync/@packages/imessage/Sources/IMessageSync
Natalie ab44591b8a fix(imessage): stop blob sync starving the periodic read cycle
The iMessage read cycle is driven by BaseSyncManager's 30s timer →
syncNow(), which is gated by 'guard !isSyncing'. performSync awaited
blobSyncManager.syncBlobs() inline, and that blob pass infinite-loops
when the upload backend is failing: /attachments/missing has no cursor,
so a full page of perpetually-failing uploads is re-fetched and re-failed
forever, the loop only breaking on a < pageSize page. performSync never
returned → isSyncing stuck true → every 30s read tick swallowed. Net
effect: messages only synced on app launch, drifting hours behind between
restarts (send-queue timers are independent, so they kept polling — the
tell that the timer fired but syncNow was gated).

Two fixes:
- Decouple the blob pass: fire it detached + in-flight-guarded instead of
  awaiting it on the read cycle, so a slow/failing blob backend can never
  hold isSyncing.
- Bound the blob loop: stop a pass after any full page that produced zero
  successful uploads (the same missing set would be re-fetched), instead
  of spinning forever.

Verified: read cycle now fires every ~30s on the live process without a
restart; blob pass logs 'stopping pass' and returns; store lag ~7s.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 14:37:40 -04:00
..
Protocols plum baseline: Phase 1/3/4/5 work (BaseSyncManager, SendQueue layer, ireminders, inotes) 2026-05-15 17:05:13 -07:00
APIClient.swift merge fixes: typecheck (attributedBody → base64 string), syncNow race coalescing, test alignment 2026-05-15 18:35:50 -07:00
BlobSyncManager.swift fix(imessage): stop blob sync starving the periodic read cycle 2026-06-23 14:37:40 -04:00
ChunkingStrategy.swift apricot baseline: contacts-sync-core + BlobSyncManager + embedding/search/sync-history 2026-05-15 17:05:39 -07:00
ModuleAccessors.swift plum baseline: Phase 1/3/4/5 work (BaseSyncManager, SendQueue layer, ireminders, inotes) 2026-05-15 17:05:13 -07:00
Reader.swift merge batch 2: imessage, iphoto, ContentTypeMapping/ConfigFile already-superset 2026-05-15 18:06:23 -07:00
Sender.swift feat(@applications/@mac-sync): add async actor-based iMessage sender with timeout guard 2026-05-22 01:56:05 -07:00
SendQueueAdapter.swift merge: restore plum-only additive files atop apricot baseline 2026-05-15 17:06:07 -07:00
SyncManager.swift fix(imessage): stop blob sync starving the periodic read cycle 2026-06-23 14:37:40 -04:00