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

Defining a property on an Ember Component named "container" causes an exception in Production build of Ember #15322

Closed
jonathanhudak opened this issue Jun 2, 2017 · 9 comments

Comments

@jonathanhudak
Copy link

jonathanhudak commented Jun 2, 2017

Hi All,

I recently encountered an issue when upgrading from Ember 2.9.1 to 2.13.0. I didn't see anything the Ember guides or docs about this, but please correct me if I missed it. It seems when you add a "container" property to a component you get the following error - only when serving your app with the production build of Ember . If this is not documented I would be happy to contribute. It seems we could also handle the exception with a more informative message to track down the source of the bug.

I was able to track down the source with the help of this SO post https://stackoverflow.com/questions/35155198/how-solve-this-using-the-injected-container-is-deprecated-ember-2-3.

I've put together a demo repo with Ember 2.13 that reproduces the bug. https://github.com/hudakdidit/ember-container-property-production-bug

To reproduce you can run ember build --environment production and put the dist folder on a running server or run a local node server like http-server.

vendor-35d6ff4933cc1e156ce04e2c2d52162f.js:12 TypeError: Cannot read property '__container__' of undefined
    at a.get (vendor-35d6ff4933cc1e156ce04e2c2d52162f.js:8)
    at R (vendor-35d6ff4933cc1e156ce04e2c2d52162f.js:12)
    at A (vendor-35d6ff4933cc1e156ce04e2c2d52162f.js:12)
    at e.H.applyPartial (vendor-35d6ff4933cc1e156ce04e2c2d52162f.js:12)
    at Function.a.proto (vendor-35d6ff4933cc1e156ce04e2c2d52162f.js:16)
    at new a (vendor-35d6ff4933cc1e156ce04e2c2d52162f.js:15)
    at Function.u.create (vendor-35d6ff4933cc1e156ce04e2c2d52162f.js:16)
    at e.create (vendor-35d6ff4933cc1e156ce04e2c2d52162f.js:8)
    at r.create (vendor-35d6ff4933cc1e156ce04e2c2d52162f.js:10)
    at vendor-35d6ff4933cc1e156ce04e2c2d52162f.js:4

@jonathanhudak jonathanhudak changed the title Defining a property on an Ember Component named "container" causes an exception Defining a property on an Ember Component named "container" causes an exception in Production build of Ember Jun 2, 2017
@jfarlow
Copy link

jfarlow commented Jun 13, 2017

Hit by the same bug. It's pretty frustrating to hit because there is no good error message, it triggers an error even before 'didInsertElement' - so there's no way to debug using standard console errors, and finally, it ONLY happens in production - so if your build times are long, it takes forever to track down in addition to just being strange that it only occurs in 'production'.

It's actually kind of scary, as it's difficult to know what else might only be going wrong in production if there is such a difference between the builds.

I moved from 2.10 to 2.13. Dev looked great, but production was completely failing without any reasonable way to trace the error. Had to essentially unbuild an entire app - as the multiple components had the issue, and was a completely unprecedented kind of bug to track down.

@GavinJoyce
Copy link
Member

GavinJoyce commented Oct 4, 2017

To summarise the issue, the following is fine in Ember 2.12, but in Ember 2.13+ it breaks on production builds, and not in development builds:

export default Ember.Component.extend({
  container: null
});

I've asked in #dev-ember to see which one of these is correct:

  1. container is a reserved word in components and we're missing a dev time error or
  2. this is a bug in Ember

@rwjblue
Copy link
Member

rwjblue commented Oct 4, 2017

Unfortunately, container certainly has been a reserved word in all objects in ember during the 2.x cycle. We have slowly moved away from that (2.3 introducing the owner API and 2.12 introducing factoryFor). Ideally in 3.0 we have no remnants of this restriction, so let’s call this a bug.

Does someone have time to submit a failing test case here that has a component with a container property (as in @GavinJoyce’s comment)? Alternatively, is there a demo app that shows the error?

@GavinJoyce
Copy link
Member

GavinJoyce commented Oct 4, 2017

@GavinJoyce
Copy link
Member

GavinJoyce commented Oct 4, 2017

I'll write the failing test for the lack of assertion. I'm not sure how to write a high level test showing the app not booting with a production build, this repo provides an example.

@GavinJoyce
Copy link
Member

GavinJoyce commented Oct 4, 2017

@rwjblue failing test for the assertion here: #15700

@GavinJoyce
Copy link
Member

Interestingly, a production build of https://github.com/hudakdidit/ember-container-property-production-bug seems to work in Ember 2.15 and 2.16, but not 2.13 or 2.14. Upgrading to 2.15 might be a good path

@pixelhandler
Copy link
Contributor

@GavinJoyce @TRMW @hudakdidit @jbailey4 @jfarlow @rwjblue is this still an issue, perhaps we should close or create a new reproduction of this, what do you think?

@jonathanhudak
Copy link
Author

Upgrading seems a like a totally valid path to resolve the issue. Closing.

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

No branches or pull requests

5 participants