emberjs/ember.js · error · Error
Could not create factory
Error message
Could not create factory
What it means
instantiateFactory reached its fall-through with no branch able to produce a value: the fullName resolved to something that is neither a singleton/class factory case the container understands. This usually means an invalid registration state rather than user input.
Source
Thrown at packages/@ember/-internals/container/lib/container.ts:420
}
return instance;
}
// SomeClass { singleton: false, instantiate: true }
if (isFactoryInstance(container, fullName, options)) {
return factoryManager.create();
}
// SomeClass { singleton: true, instantiate: false } | { instantiate: false } | { singleton: false, instantiation: false }
if (
isSingletonClass(container, fullName, options) ||
isFactoryClass(container, fullName, options)
) {
return factoryManager.class;
}
throw new Error('Could not create factory');
}
function destroyDestroyables(container: Container): void {
let cache = container.cache;
let keys = Object.keys(cache);
for (let key of keys) {
let value = cache[key];
assert('has cached value', value);
if ((value as any).destroy) {
(value as any).destroy();
}
}
}
function resetCache(container: Container) {
container.cache = dictionary(null);View on GitHub (pinned to 26f97246a8)
Solutions
- Use standard registration/lookup patterns (register + lookup with default options)
- Check the options passed to lookup/register for stray { instantiate: false }
- Verify the fullName is properly registered and normalized
- Upgrade ember-source — internal factory handling has changed over versions
Defensive patterns
Strategy: validation
Validate before calling
if (!owner.hasRegistration(fullName)) throw new Error(`Not registered: ${fullName}`); Type guard
function isRegistrableName(n) { return typeof n === 'string' && n.includes(':'); } Try / catch
try { return owner.lookup(fullName, opts); } catch (e) { if (e.message === 'Could not create factory') { /* fix registration/options */ } throw e; } Prevention
- Use standard register/lookup with default options
- Avoid mixing { instantiate: false } with factory-class paths
- Verify fullName validity before lookup
- Keep container internals unmodified
When it happens
Trigger: lookup() on a name whose cached/factory state matches none of the recognized shapes (not a singleton instance, not a singleton class, not a factory class) — typically from an unusual custom RegisterOptions combination or corrupted cache.
Common situations: Custom container/registry experimentation; options like { instantiate: false } combined unexpectedly with singleton/factory class registrations; internal misuse from engines or custom resolvers.
Related errors
- Cannot call `.lookup('${fullName}')` after the owner has bee
- Cannot call `.factoryFor('${fullName}')` after the owner has
- You attempted to set "${String(prop)}" on a factory manager
- Cannot create new instances after the owner has been destroy
- The API deprecated by ${options.id} was removed in ember-sou
AI-assisted analysis of emberjs/ember.js@26f97246a8 (2026-09-01).
Data as JSON: /api/errors/5d55cab8dfb5af6a.
Report an issue: GitHub.