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

Attempting to inject an unknown injection: service:-document #77

Closed
simonihmig opened this issue Nov 15, 2016 · 11 comments
Closed

Attempting to inject an unknown injection: service:-document #77

simonihmig opened this issue Nov 15, 2016 · 11 comments

Comments

@simonihmig
Copy link
Contributor

Since having upgraded to ember-wormhole 0.5.1 in our Ember 2.7 based app I see this exception. Seems to be related to #75.

I saw this in one of our apps after updating ember-light-table, that brings in ember-wormhole 0.5.1. Added an ember-try config for Ember 2.7 here: adopted-ember-addons/ember-light-table#267, which is failing for 2.7 (see the Travis logs), probably also 2.6 (not tested).

Also tried to update ember-wormhole in my own addon ember-bootstrap (ember-bootstrap/ember-bootstrap#160) and see the same exception (see the Travis logs), for 2.7 and 2.6.

The stack trace is unfortunately cut off too early in the Travis logs, but when running tests in Chrome I saw the stack trace touching this line actually: https://github.com/yapplabs/ember-wormhole/blob/master/addon/utils/dom.js#L54. So it was not failing here https://github.com/yapplabs/ember-wormhole/blob/master/addon/utils/dom.js#L50, documentService was undefined as expected.

Tried to reproduce this within ember-wormhole itself by adding an ember-try scenario for 2.7, however that did not fail! Strange enough...

@lukemelia
Copy link
Contributor

@krisselden @rwjblue Any suggestions?

@offirgolan
Copy link

@simonihmig thanks for adding the failing test cases in ELT. I've been getting the same failures with ember-burger-menu for Ember 2.6 and 2.7.

@simonihmig
Copy link
Contributor Author

Any news on this one? /cc @krisselden @rwjblue

As Ember 2.10 is out, we have the choice of either using ember-wormhole 0.5.1 (which has these issues with 2.6/2.7) or stick to 0.4.1 (which seems to have issues with Ember 2.10, for me at least in a Fastboot env), but apparently currently no version that runs flawlessly in all Ember versions.

@Gaurav0
Copy link

Gaurav0 commented Feb 2, 2017

@lukemelia @offirgolan @simonihmig @anulman

Actually, "service:-document" does exist in Ember 2.6 and 2.7 but in any case it is a faux service that returns window.document in the browser (and something else in Fastboot).

You can get an integration test to pass by adding the following to beforeEach():

this.register('service:-document', window.document, { instantiate: false });

(I learned all this from talking to @runspired)

@simonihmig
Copy link
Contributor Author

@Gaurav0 OK, but that fixes the test, but not the app!? 😳

It is not an issue within tests only, it is real!

@Gaurav0
Copy link

Gaurav0 commented Feb 2, 2017

@simonihmig If you're not using Fastboot / SSR, just add an initializer that registers service:-document the same way. If you are, right now I would just recommend upgrading to 2.8.

@simonihmig
Copy link
Contributor Author

The problem I have with that is that I use ember-wormhole in an addon (ember-bootstrap), as do many others (see above for references to ember-light-table, ember-burger-menu, ember-basic-dropdown). Won't add an initializer there for "fixing" things in a dependency.

@cibernox
Copy link
Collaborator

cibernox commented Feb 2, 2017

Could the addon detect the ember version and only use service:-document in 2.8+?

@Gaurav0
Copy link

Gaurav0 commented Feb 2, 2017

@simonihmig I would recommend for your addon, until this bug is fixed, to:

  1. Use the registry fix I used above to get your addon's tests to pass.
  2. Point any users of old Ember versions here if their app doesn't work so they can add the initializer.

@simonihmig
Copy link
Contributor Author

I revisited this today...

It is not an issue within tests only, it is real!

Interestingly I could not confirm what I said here today. So basically integrations tests were failing with the mentioned exception, but I could not reproduce this in a real app...

The approach @Gaurav0 mentioned here did work for fixing the tests with Ember 2.6/2.7, but threw with later versions of Ember...

So I came up with #95 which should fix these problems, without anybody having to touch their tests!

@simonihmig
Copy link
Contributor Author

Forgot to close this. Fixed this in #95

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

5 participants