emberjs/ember.js · error · Error

You attempted to set "${String(prop)}" on a factory manager

Error message

You attempted to set "${String(prop)}" on a factory manager created by container#factoryFor. A factory manager is a read-only construct.

What it means

The object returned by factoryFor is wrapped in a read-only deprecation proxy; assigning any property on it throws. Factory managers expose .class/.create and are not mutable extension points.

Source

Thrown at packages/@ember/-internals/container/lib/container.ts:248

    return factoryFor(this, normalizedName, fullName);
  }
}

if (DEBUG) {
  Container._leakTracking = leakTracking!;
}

/*
 * Wrap a factory manager in a proxy which will not permit properties to be
 * set on the manager.
 */
function wrapManagerInDeprecationProxy<T extends object, C extends object | FactoryClass>(
  manager: InternalFactoryManager<T, C>
): InternalFactoryManager<T, C> {
  let validator = {
    set(_obj: T, prop: keyof T) {
      throw new Error(
        `You attempted to set "${String(
          prop
        )}" on a factory manager created by container#factoryFor. A factory manager is a read-only construct.`
      );
    },
  };

  // Note:
  // We have to proxy access to the manager here so that private property
  // access doesn't cause the above errors to occur.
  let m = manager;
  let proxiedManager = {
    class: m.class,
    create(props?: Partial<T>) {
      return m.create(props);
    },
  };

View on GitHub (pinned to 26f97246a8)

Solutions

  1. Stop mutating the factory; register a subclass or use an initializer with register() instead
  2. If you need configured instances, pass options to manager.create(props)
  3. Fix accidental '=' assignment intended as comparison

Example fix

// before
let factory = owner.factoryFor('service:store');
factory.someFlag = true;
// after
owner.register('service:store', MyConfiguredStore);
Defensive patterns

Strategy: type-guard

Validate before calling

let mgr = owner.factoryFor('service:foo'); console.assert(Object.isFrozen(mgr) || mgr instanceof Object); // treat as read-only

Type guard

function isFactoryManager(v) { return v && typeof v.create === 'function' && 'class' in v; }

Try / catch

try { mgr[prop] = value; } catch (e) { if (String(e.message).includes('read-only construct')) { /* register subclass instead */ } else throw e; }

Prevention

When it happens

Trigger: Writing to a property on the result of factoryFor, e.g. factoryFor('service:x').class.someProp = 1, or doing Object.assign on the manager.

Common situations: Attempting monkey-patching of a factory/class via the manager (a pattern from old Ember.Factory usage); accidental assignment instead of comparison (= vs ==) in code touching the manager.

Related errors


AI-assisted analysis of emberjs/ember.js@26f97246a8 (2026-09-01). Data as JSON: /api/errors/d505df9a8781df1c. Report an issue: GitHub.