tchak / ember-fetch-adapter

A Network Adapter Service based on Ember RFC #171.
MIT License
1 stars 1 forks source link

Error: Assertion Failed: Expected service:adapter to resolve to an Ember.Service but instead it was [object Object] #1

Closed RobbieTheWagner closed 6 years ago

RobbieTheWagner commented 6 years ago

I seem to be getting an error trying to inject the service.

Error: Assertion Failed: Expected service:adapter to resolve to an Ember.Service but instead it was [object Object].
    at new EmberError (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/@ember/error/index.js:40:1)
    at assert (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/@ember/debug/index.js:132:1)
    at validateType (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/@ember/application/lib/validate-type.js:23:1)
    at Class.resolve (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/@ember/application/globals-resolver.js:142:1)
    at _resolve (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/container.js:889:1)
    at Registry.resolve (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/container.js:591:1)
    at Registry.resolve (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/container.js:595:1)
    at _has (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/container.js:906:1)
    at Registry.has (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/container.js:642:1)
    at Registry.validateInjections (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/container.js:841:1)
    at FactoryManager.create (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/container.js:407:1)
    at instantiateFactory (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/container.js:249:1)
    at _lookup (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/container.js:181:1)
    at Container.lookup (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/container.js:78:1)
    at Class.lookup (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/ember-runtime/lib/mixins/container_proxy.js:23:1)
    at UnresolvedHandlerInfoByParam.getHandler (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/ember-routing/lib/system/router.js:418:1)
    at UnresolvedHandlerInfoByParam.fetchHandler (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/router.js:575:1)
    at UnresolvedHandlerInfoByParam.get (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/router.js:734:1)
    at URLTransitionIntent.applyToState (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/router.js:1160:1)
    at Router.getTransitionByIntent (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/router.js:1473:1)
    at Router.transitionByIntent (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/router.js:1280:1)
    at doTransition (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/router.js:1908:1)
    at Router.handleURL (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/router.js:1311:1)
    at Class._doURLTransition (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/ember-routing/lib/system/router.js:258:1)
    at Class.handleURL (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/ember-routing/lib/system/router.js:255:1)
    at Class.visit (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/@ember/application/instance.js:189:1)
    at buildAppInstance.then.then (/Users/rwwagner/shipshape/shipshape.io/node_modules/ember-cli-fastboot/node_modules/fastboot/src/ember-app.js:260:28)
    at tryCatcher (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/rsvp.js:200:1)
    at invokeCallback (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/rsvp.js:372:1)
    at publish (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/rsvp.js:358:1)
    at /Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/ember-testing/lib/ext/rsvp.js:14:1
    at invokeWithOnError (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/backburner.js:256:1)
    at Queue.flush (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/backburner.js:167:1)
    at DeferredActionQueues.flush (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/backburner.js:326:1)
    at Backburner._end (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/backburner.js:772:1)
    at Backburner._boundAutorunEnd (/Users/rwwagner/shipshape/shipshape.io/tmp/broccoli_merge_trees-output_path-vbYM6jwK.tmp/assets/backburner.js:484:1)
    at process._tickCallback (internal/process/next_tick.js:178:7)
tchak commented 6 years ago

Can you tell me your app Ember version?

tchak commented 6 years ago

I added an injection test, and really can't see the problem...

I also just found your app source, I will try it later today to see what is happening.

RobbieTheWagner commented 6 years ago

The branch I tried it on is https://github.com/shipshapecode/shipshape.io/tree/bssj

tchak commented 6 years ago

The error you are experiencing is in fastboot, right?

RobbieTheWagner commented 6 years ago

@tchak yes. You can pull down that branch and run it and see the error by navigating to the blog, and doing a hard refresh, I believe.

tchak commented 6 years ago

@rwwagner90 I am not sure what was the case, but I just tried your branch and it worked with the last version of ember-fetch-adapter. I needed to add hostWhitelist: [/^localhost:\d+$/] though.

RobbieTheWagner commented 6 years ago

@tchak I will try the latest, but it doesn't look like anything changed really. I expect the issue to be reproducible. Was there an error without hostWhitelist?

RobbieTheWagner commented 6 years ago

@tchak it seems that installing ember-fetch alongside ember-fetch-adapter makes things work again. I supposed having it in dependencies here isn't enough for some reason?

dfreeman commented 6 years ago

Guessing this is tied to https://github.com/ember-cli/ember-fetch/issues/98?

RobbieTheWagner commented 6 years ago

I'm now hitting another issue, trying to use this with prember.

7:27:23 AM: Error while processing route: blog.index Only HTTP(S) protocols are supported TypeError: Only HTTP(S) protocols are supported
7:27:23 AM:     at getNodeRequestOptions (/opt/build/repo/node_modules/node-fetch/lib/index.js:1288:9)
7:27:23 AM:     at /opt/build/repo/node_modules/node-fetch/lib/index.js:1370:19
7:27:23 AM:     at new Promise (<anonymous>)
7:27:23 AM:     at fetch (/opt/build/repo/node_modules/node-fetch/lib/index.js:1367:9)
7:27:23 AM:     at abortableFetch (/opt/build/repo/node_modules/abortcontroller-polyfill/dist/cjs-ponyfill.js:290:12)
7:27:23 AM:     at n.value [as makeRequest] (/opt/build/repo/tmp/prember-input_base_path-NFp5JPSm.tmp/assets/vendor.js:4358:90)
7:27:23 AM:     at /opt/build/repo/tmp/prember-input_base_path-NFp5JPSm.tmp/assets/vendor.js:4346:170
7:27:23 AM:     at <anonymous>

Any ideas?

dfreeman commented 6 years ago

@rwwagner90 Yeah, I've seen some weird behavior in Prember where you wind up with the fastboot service reporting a protocol of "undefined:" https://github.com/ember-learn/ember-cli-addon-docs/pull/179/files#diff-4a0c31f2b4c62182ee0685e126f0147fR18

There may be something that needs to be fixed upstream, but in the interim ember-fetch-adapter might want to add an explicit check for that.

tchak commented 6 years ago

I released a new version. Can you try and close this if the problem is solved.

Thanks @rwwagner90 and @dfreeman for working this out!

RobbieTheWagner commented 6 years ago

With the protocol fix and the addition of the blueprint, this issue should be resolved.