question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getOwner(this): inconsistent behavior for dev/prod

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
stefanpennercommented, Jul 14, 2017

@jamesarosen keep us posted

1reaction
jamesarosencommented, Jul 14, 2017

Please give 2.14.1 a go

We’ll be doing that over the next few days I hope 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

getOwner - 4.9 - Ember API Documentation
An owner object. Framework objects in an Ember application (components, services, routes, etc.) are created via a factory and dependency injection system. Each ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found