mastra-ai/mastra · error

Memory storage domain is not available on ${this.storage.con

Error message

Memory storage domain is not available on ${this.storage.constructor.name}

What it means

Memory methods need the 'memory' storage domain, fetched via this.storage.getStore('memory'). When the configured Storage class does not expose a memory domain (returns undefined), this error is thrown. It indicates the storage backend is incompatible or misconfigured rather than that data is missing.

Source

Thrown at packages/memory/src/index.ts:558

          vector: this.vector!,
          embedder: this.embedder!,
          embedderOptions: this.embedderOptions,
        }),
    );
    return this._knowledgeSemanticIndex;
  }

  public async drainKnowledgeSemanticIndex(scope?: KnowledgeScope): Promise<number> {
    return (await this.getKnowledgeSemanticIndex()).drain(scope);
  }

  /**
   * Gets the memory storage domain, throwing if not available.
   */
  protected async getMemoryStore(): Promise<MemoryStorage> {
    const store = await this.storage.getStore('memory');
    if (!store) {
      throw new Error(`Memory storage domain is not available on ${this.storage.constructor.name}`);
    }
    return store;
  }

  async listMessagesByResourceId(args: StorageListMessagesByResourceIdInput): Promise<StorageListMessagesOutput> {
    const memoryStore = await this.getMemoryStore();
    return memoryStore.listMessagesByResourceId(args);
  }

  protected async validateThreadIsOwnedByResource(threadId: string, resourceId: string, config: MemoryConfigInternal) {
    const resourceScope =
      (typeof config?.semanticRecall === 'object' && config?.semanticRecall?.scope !== `thread`) ||
      config.semanticRecall === true;

    const thread = await this.getThreadById({ threadId });

    // For resource-scoped semantic recall, we don't need to validate that the specific thread exists
    // because we're searching across all threads for the resource

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Upgrade @mastra/* storage packages so the Storage class implements domain stores including 'memory'
  2. Use an official storage backend (LibSQLStore, PostgresStore, UpstashStore, etc.) instead of a custom or partial implementation
  3. If custom storage, implement getStore('memory') returning a MemoryStorage domain

Example fix

// before
const memory = new Memory({ storage: new MyCustomStore() });
// after
const memory = new Memory({ storage: new LibSQLStore({ url: 'file:./mastra.db' }) });
Defensive patterns

Strategy: validation

Validate before calling

const store = await storage.getStore('memory');
if (!store) throw new Error('Storage backend does not provide a memory domain; use an official @mastra storage package');

Type guard

function hasMemoryDomain(s: unknown): s is { getStore: (d: string) => Promise<unknown> } {
  return typeof s === 'object' && s !== null && 'getStore' in s;
}

Prevention

When it happens

Trigger: Calling any Memory method that touches messages/threads (e.g. listMessagesByResourceId, remember, recall) when this.storage is a class whose getStore('memory') returns undefined — e.g. a custom/incomplete Storage implementation, a legacy storage adapter predating domain stores, or passing a non-Mastra storage object.

Common situations: Using an outdated @mastra/storage version with a newer @mastra/core memory that expects domain stores; implementing a custom Storage class without a memory domain; passing the wrong object (e.g. a vector store) as storage.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/c5a93ea206ab3b95. Report an issue: GitHub.