mastra-ai/mastra · error
Factory storage domain '${name}' is not registered
Error message
Factory storage domain '${name}' is not registered What it means
getDomain() looks a domain up by name in the storage's registered-domain map and throws when no domain with that name exists. This is a fast-fail so callers get a clear error instead of an undefined domain causing a TypeError later.
Source
Thrown at packages/core/src/storage/factory-storage.ts:302
await Promise.all([...this.#domains.keys()].map(name => this.#initDomain(name).catch(() => undefined)));
}
/** Backend-specific connection initialization. */
protected abstract initStorage(): Promise<void>;
registerDomain<T extends FactoryStorageDomain>(domain: T): T {
if (this.#domains.has(domain.name)) {
throw new Error(`Factory storage domain '${domain.name}' is already registered`);
}
domain.__bindFactoryStorage(this);
this.#domains.set(domain.name, domain);
return domain;
}
getDomain<T extends FactoryStorageDomain = FactoryStorageDomain>(name: string): T {
const domain = this.#domains.get(name);
if (!domain) {
throw new Error(`Factory storage domain '${name}' is not registered`);
}
return domain as T;
}
hasDomain(name: string): boolean {
return this.#domains.has(name);
}
domainNames(): string[] {
return [...this.#domains.keys()];
}
isDomainReady(name: string): boolean {
return this.#readyDomains.has(name);
}
domainInitError(name: string): unknown {
return this.#domainErrors.get(name);View on GitHub (pinned to 75dd419e61)
Solutions
- Use `storage.hasDomain(name)` to check before getDomain, or use the typed accessor (e.g. `storage.memorySettings`) instead of string lookup.
- Verify the exact domain name registered by your storage backend's initStorage().
- Ensure the owning storage has been initialized before lookups.
- Confirm you are calling on the same storage instance where the domain was registered.
Example fix
// before
const d = storage.getDomain('memory-setting'); // typo: throws
// after
if (storage.hasDomain('memorySettings')) {
const d = storage.getDomain('memorySettings');
} Defensive patterns
Strategy: validation
Validate before calling
const DOMAIN_NAMES = ['intake','audit','workItems','modelCredentials','modelPacks','memorySettings'];
function domainExists(storage, name) {
return storage.hasDomain(name);
} Try / catch
try {
const d = storage.getDomain(name);
} catch (e) {
if (e.message.includes('is not registered')) {
throw new Error(`Domain "${name}" missing; did storage.init() run and is the name spelled correctly?`);
}
throw e;
} Prevention
- Prefer typed accessors over string-based getDomain where available.
- Keep domain name strings in a shared constant module to avoid typos.
- Verify the storage backend actually registers the domain you request.
- Log the list of registered names (via hasDomain checks) when debugging lookups.
When it happens
Trigger: Calling `storage.getDomain('someName')` (directly or via ensureDomainReady/domain helpers) where 'someName' was never registered on this storage instance, or with a typo/mismatched domain name.
Common situations: Typo in the domain name string; querying a domain on a different storage instance than the one where it was registered; calling before initStorage() ran; version changes where a domain was renamed.
Related errors
- GithubIntegration storage has not been initialized.
- GithubIntegration source-control storage has not been initia
- Factory storage domain '${this.name}' has not been registere
- Memory storage is not initialized
- AcpAgent does not support resuming suspended generate calls
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/f0ec116bfcae8742.
Report an issue: GitHub.