{"record":{"id":"7ddbdcd5faf329de","repo":"thedotmack/claude-mem","slug":"backfill-failed-error-instanceof-error-error","errorCode":null,"errorMessage":"Backfill failed: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Backfill failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/services/sync/ChromaSync.ts","lineNumber":775,"sourceCode":"    logger.info('CHROMA_SYNC', 'Bootstrapped watermarks from Chroma', {\n      project,\n      watermarks: ChromaSyncState.get(project)\n    });\n  }\n\n  async ensureBackfilled(project: string, store: SessionStore): Promise<void> {\n    logger.info('CHROMA_SYNC', 'Starting smart backfill', { project });\n\n    await this.ensureCollectionExists();\n\n    this.backfillAborted = false;\n    const watermarks = ChromaSyncState.get(project);\n\n    try {\n      await this.runBackfillPipeline(store, project, watermarks);\n    } catch (error) {\n      logger.error('CHROMA_SYNC', 'Backfill failed', { project }, error instanceof Error ? error : new Error(String(error)));\n      throw new Error(`Backfill failed: ${error instanceof Error ? error.message : String(error)}`);\n    }\n  }\n\n  private async runBackfillPipeline(\n    db: SessionStore,\n    backfillProject: string,\n    watermarks: ProjectWatermarks\n  ): Promise<void> {\n    const observationDocs = await this.backfillObservations(db, backfillProject, watermarks.observations);\n    if (this.backfillAborted) {\n      return;\n    }\n    const summaryDocs = await this.backfillSummaries(db, backfillProject, watermarks.summaries);\n    if (this.backfillAborted) {\n      return;\n    }\n    const promptDocs = await this.backfillPrompts(db, backfillProject, watermarks.prompts);\n    if (this.backfillAborted) {","sourceCodeStart":757,"sourceCodeEnd":793,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/sync/ChromaSync.ts#L757-L793","documentation":"ChromaSync.ensureBackfilled runs the backfill pipeline to bring Chroma up to the persisted watermarks. If runBackfillPipeline throws for any reason, the error is logged and re-thrown wrapped as 'Backfill failed: <cause>'. The wrapper discards the original stack, so the inner message is the only diagnostic carried to the caller.","triggerScenarios":"Any failure inside runBackfillPipeline: Chroma unavailable, MCP mutation errors, queue-full/cancelled errors (130/131), or DB read failures while walking sessions since the watermark.","commonSituations":"Chroma MCP server down during startup backfill, network drop mid-backfill, corrupted or too-new watermark state, or mutation backpressure aborting the pipeline.","solutions":["Read the inner message after 'Backfill failed:' to identify the root cause (connection lost, queue full, etc.) and fix that first.","Check Chroma MCP server availability and restart it if unreachable.","Delete/reset the stored watermarks (ChromaSyncState) if they are inconsistent, forcing a clean re-backfill.","Retry the backfill after the connection recovers; backfill is idempotent up to the watermark.","If the wrapper hides the stack too often, log/rethrow the original error object instead of a new Error."],"exampleFix":"// before (in ChromaSync.ts)\nthrow new Error(`Backfill failed: ${error instanceof Error ? error.message : String(error)}`);\n// after: preserve cause for debugging\nthrow new Error(`Backfill failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error });","handlingStrategy":"retry","validationCode":"// pre-checks before ensureBackfilled\nif (!chromaServerHealthy()) throw new Error('Chroma unreachable; fix server before backfill');\nconst watermarks = ChromaSyncState.get(project);\nif (!watermarks || typeof watermarks !== 'object') resetWatermarks(project);","typeGuard":null,"tryCatchPattern":"try {\n  await chromaSync.ensureBackfilled(store, project);\n} catch (e) {\n  logger.error('backfill failed', { cause: e });\n  const rootCause = String(e.message).replace(/^Backfill failed: /, '');\n  await scheduleRetryWithBackoff(() => chromaSync.ensureBackfilled(store, project));\n}","preventionTips":["Check Chroma MCP health before starting backfill","Keep the original error as { cause } when wrapping for diagnosis","Make backfill retries scheduled and idempotent via watermarks","Alert on repeated 'Backfill failed' messages per project"],"tags":["backfill","chroma","sync","wrapped-error"],"backgroundTag":"backfill-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"}