mem0ai/mem0 · error · Error

Failed to insert vectors: ${error instanceof Error ? error.m

Error message

Failed to insert vectors: ${error instanceof Error ? error.message : String(error)}

What it means

Generic catch wrapper around the Vectorize insert path: any thrown error (including the non-ok HTTP error, network failure, or TypeError while building the request) is logged and rethrown wrapped as 'Failed to insert vectors: <message>'. The inner message identifies the real cause — treat this as the outer envelope of error 313 plus network/serialization failures.

Source

Thrown at mem0-ts/src/oss/src/vector_stores/vectorize.ts:84

        {
          method: "POST",
          headers: {
            "Content-Type": "application/x-ndjson",
            Authorization: `Bearer ${this.client?.apiToken}`,
          },
          body: ndjsonPayload,
        },
      );

      if (!response.ok) {
        const errorText = await response.text();
        throw new Error(
          `Failed to insert vectors: ${response.status} ${errorText}`,
        );
      }
    } catch (error) {
      console.error("Error inserting vectors:", error);
      throw new Error(
        `Failed to insert vectors: ${error instanceof Error ? error.message : String(error)}`,
      );
    }
  }

  async keywordSearch(): Promise<null> {
    return null;
  }

  async search(
    query: number[],
    topK: number = 5,
    filters?: SearchFilters,
  ): Promise<VectorStoreResult[]> {
    await this.initialize();
    try {
      const result = await this.client?.vectorize.indexes.query(
        this.indexName,

View on GitHub (pinned to 001c235229)

Solutions

  1. Inspect the wrapped message — it contains the underlying cause; apply the matching fix (auth, index name, dimensions).
  2. For transient network/5xx causes, retry the add operation with backoff (idempotent if you control the memory id).
  3. Rotate the API token if the inner message indicates 401/invalid credentials.
Defensive patterns

Strategy: retry

Try / catch

const isTransient = (m: string) => /timeout|ECONNRESET|5\d\d/.test(m);
try { await memory.add(text); } catch (e) { const m = e instanceof Error ? e.message : String(e); if (m.startsWith('Failed to insert vectors:') && isTransient(m)) await retryWithBackoff(() => memory.add(text), 3); else throw e; }

Prevention

When it happens

Trigger: Any exception during memory.add() on Cloudflare Vectorize: DNS/network failure reaching api.cloudflare.com, a fetch TypeError, an expired token producing 401 from the inner throw, or a dimension mismatch surfaced through the inner error.

Common situations: Transient network issues in serverless environments; expired or rotated Cloudflare API tokens; intermittent Cloudflare API 5xx responses.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/1df58a2cc2c69c6b. Report an issue: GitHub.