thedotmack/claude-mem · warning

Cloud sync flush failed; unsynced rows remain queued

Error message

Cloud sync flush failed; unsynced rows remain queued

What it means

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.

Solutions

  1. Check this.lastError / logged err for the root cause (network vs HTTP status vs auth).
  2. If auth-related, refresh credentials/API key and let the backoff retry succeed.
  3. Verify network connectivity; flush resumes automatically via scheduleRetry and notify().
  4. Check cloud service status/endpoint health if 5xx persists.
  5. Reduce flush batch size if payload-too-large errors occur.
Defensive patterns

Strategy: retry

Validate before calling

// probe connectivity/auth before flushing
const res = await fetch(cloudEndpoint, { method: 'HEAD' });
if (!res.ok) console.warn(`cloud endpoint unhealthy: ${res.status}; flush will retry`);

Try / catch

try { await flush(); }
catch (e) {
  const err = e instanceof Error ? e : new Error(String(e));
  console.warn(`flush failed; rows stay queued, retry in ${nextBackoffMs}ms`, err);
  scheduleRetry();
}

Prevention

When it happens

Trigger: The HTTP upload inside flush throws — network offline, auth token expired, server 5xx, payload rejected, timeout — during start() or a timer-driven flush.

Common situations: Laptop offline or sleeping mid-sync, expired API credentials, cloud service outage, oversized flush payload hitting server limits.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17). Data as JSON: /api/errors/2ee64570594238c7. Report an issue: GitHub.

Appendix: source

Thrown at src/services/sync/CloudSync.ts:598

    try {
      this.dropStaleOriginDeviceIdSnapshots();
      do {
        this.flushAgainRequested = false;
        await this.drainContentOutbox();
        await this.drainMutations();
        for (const kind of KINDS) {
          await this.drainKind(kind);
        }
      } while (this.flushAgainRequested && !this.stopped);
      if (this.stopped) return; // shutdown mid-flush — skip success bookkeeping
      this.lastFlushAt = Date.now();
      this.lastError = null;
      this.resetBackoff();
    } catch (error) {
      const err = error instanceof Error ? error : new Error(String(error));
      this.lastError = err.message;
      // Rows stay NULL — retried by the backoff timer below and on next notify().
      logger.warn('CLOUD_SYNC', 'Cloud sync flush failed; unsynced rows remain queued', {
        retryInMs: this.nextBackoffMs,
      }, err);
      this.scheduleRetry();
    } finally {
      this.flushing = false;
    }
  }

  status(): CloudSyncStatus {
    return {
      configured: this.isConfigured(),
      deviceId: this.deviceId,
      pending: {
        observations: this.countPending('observations'),
        summaries: this.countPending('session_summaries'),
        prompts: this.countPending('user_prompts'),
        mutations: this.countPendingMutations(),
        tombstones: this.countPendingTombstones(),

View on GitHub (pinned to d8bc9755e7)