getOwner(this): inconsistent behavior for dev/prod
See original GitHub issueI have a factory for typesafe enumerations:
export default function typesafeEnum(ids, klass) {
ids = array(ids);
assert('ids must be an array of length > 0', ids.length > 0);
klass = klass || Ember.Object;
return ArrayProxy.extend({
container: null, // <-- note this line
content: computed(function() {
const owner = getOwner(this);
return ids.map((id) => {
const result = klass.create({ id });
setOwner(result, owner);
return result;
});
})
});
}
The container: null was originally there just to remind consumers that they had to provide one. Before Ember 1.13, when I created one of those things and passed in a container, everything worked fine. On Ember 1.13 in development and test mode, everything continued to work fine and emitted no warnings.
But when we hit production, this blew up here because getOwner(this) was undefined on the ArrayProxy instance. Removing container: null fixed the problem.
It concerns me that Ember’s core object classes have differing behavior in dev/test vs prod, especially since there aren’t even any warnings for this in dev/test. (I’m not concerned with the change in behavior from 1.12 to 1.13. We were doing something weird. But our dev/test environments should have caught the problem during the upgrade.)
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)

Top Related StackOverflow Question
@jamesarosen keep us posted
We’ll be doing that over the next few days I hope 😃