Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getOwner(this): inconsistent behavior for dev/prod #15507

Closed
jamesarosen opened this issue Jul 14, 2017 · 5 comments
Closed

getOwner(this): inconsistent behavior for dev/prod #15507

jamesarosen opened this issue Jul 14, 2017 · 5 comments

Comments

@jamesarosen
Copy link

jamesarosen commented Jul 14, 2017

I 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.)

@jamesarosen
Copy link
Author

:)

@stefanpenner
Copy link
Member

@jamesarosen the issue was a JSC JIT bug, so its hard to tell if your exact scenario was addressed by the work-around. Please give 2.14.1 a go, if it doesn't resolve it, comment here \w reproduction (if possible) and we can reopen.

@jamesarosen
Copy link
Author

Please give 2.14.1 a go

We'll be doing that over the next few days I hope :)

@stefanpenner
Copy link
Member

@jamesarosen keep us posted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants