{"record":{"id":"2ee64570594238c7","repo":"thedotmack/claude-mem","slug":"cloud-sync-flush-failed-unsynced-rows-remain-queu","errorCode":null,"errorMessage":"Cloud sync flush failed; unsynced rows remain queued","messagePattern":"Cloud sync flush failed; unsynced rows remain queued","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/services/sync/CloudSync.ts","lineNumber":598,"sourceCode":"    try {\n      this.dropStaleOriginDeviceIdSnapshots();\n      do {\n        this.flushAgainRequested = false;\n        await this.drainContentOutbox();\n        await this.drainMutations();\n        for (const kind of KINDS) {\n          await this.drainKind(kind);\n        }\n      } while (this.flushAgainRequested && !this.stopped);\n      if (this.stopped) return; // shutdown mid-flush — skip success bookkeeping\n      this.lastFlushAt = Date.now();\n      this.lastError = null;\n      this.resetBackoff();\n    } catch (error) {\n      const err = error instanceof Error ? error : new Error(String(error));\n      this.lastError = err.message;\n      // Rows stay NULL — retried by the backoff timer below and on next notify().\n      logger.warn('CLOUD_SYNC', 'Cloud sync flush failed; unsynced rows remain queued', {\n        retryInMs: this.nextBackoffMs,\n      }, err);\n      this.scheduleRetry();\n    } finally {\n      this.flushing = false;\n    }\n  }\n\n  status(): CloudSyncStatus {\n    return {\n      configured: this.isConfigured(),\n      deviceId: this.deviceId,\n      pending: {\n        observations: this.countPending('observations'),\n        summaries: this.countPending('session_summaries'),\n        prompts: this.countPending('user_prompts'),\n        mutations: this.countPendingMutations(),\n        tombstones: this.countPendingTombstones(),","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/sync/CloudSync.ts#L580-L616","documentation":"CloudSync.flush pushes queued rows (with NULL synced markers) to the cloud API. On any error, rows remain queued (still NULL), lastError is set, and an exponential-backoff retry is scheduled; this warning reports the failure and next retry delay.","triggerScenarios":"The HTTP upload inside flush throws — network offline, auth token expired, server 5xx, payload rejected, timeout — during start() or a timer-driven flush.","commonSituations":"Laptop offline or sleeping mid-sync, expired API credentials, cloud service outage, oversized flush payload hitting server limits.","solutions":["Check this.lastError / logged err for the root cause (network vs HTTP status vs auth).","If auth-related, refresh credentials/API key and let the backoff retry succeed.","Verify network connectivity; flush resumes automatically via scheduleRetry and notify().","Check cloud service status/endpoint health if 5xx persists.","Reduce flush batch size if payload-too-large errors occur."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// probe connectivity/auth before flushing\nconst res = await fetch(cloudEndpoint, { method: 'HEAD' });\nif (!res.ok) console.warn(`cloud endpoint unhealthy: ${res.status}; flush will retry`);","typeGuard":null,"tryCatchPattern":"try { await flush(); }\ncatch (e) {\n  const err = e instanceof Error ? e : new Error(String(e));\n  console.warn(`flush failed; rows stay queued, retry in ${nextBackoffMs}ms`, err);\n  scheduleRetry();\n}","preventionTips":["Keep credentials refreshed and validate them at startup","Monitor lastError for persistent failure patterns","Ensure notify() is called after network recovery to trigger an early flush","Keep flush payloads within server size limits","Treat queued (NULL-synced) rows as durable; never drop them on flush error"],"tags":["cloud","http","retry","backoff"],"backgroundTag":"http-request-failed","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}