Ember.js: Errors with `transitionTo` since upgrading to 3.0.0

Created on 26 Mar 2018  ·  3Comments  ·  Source: emberjs/ember.js

I've upgraded a couple of projects to 3.0.0 now and while one of them is fine the other one throws errors whenever I call transitionTo, such as

router.js:1011 Uncaught Error: More context objects were passed than there are dynamic segments for the route: projects
    at NamedTransitionIntent.applyToHandlers (router.js:1011)
    at NamedTransitionIntent.applyToState (router.js:940)
    at Router.getTransitionByIntent (router.js:1229)
    at Router.transitionByIntent (router.js:1348)
    at doTransition (router.js:1947)
    at Router.transitionTo (router.js:1418)
    at Class._doTransition (router.js:561)
    at Class.transitionTo (routing.js:18)
    at session.save.then.s (session.js:104)
    at tryCatcher (rsvp.js:215)

It seems the issue is in applyToHandlers:

var objects = this.contexts.slice(0);
// ...
if (objects.length > 0) {
  throw new Error('More context objects were passed than there are dynamic segments for the route: ' + targetRouteName);
}

From looking at it with the debugger it seems to go through this twice for some reason, and on the first pass objects is [] (as it should be as there's no dynamic segments here) but on the second it's [undefined] which fails the length validation.

Seeing as I don't get this issue in my other app I'm not sure if I've hit an edge case with Ember or an issue with my own code here and I'm wondering if you could point me in a direction where I could look into this further.

Needs Reproduction

Most helpful comment

A bit of digging around and I've discovered this only happens in services where I've used the private routing service: routing: service('-routing').

Replacing it with router: service() fixes my issue but is there anywhere this is documented? I was under the impression the public router service was still to come.

All 3 comments

Hmm, seems like it is probably related to your setup (haven't seen this reported by others), could you try to isolate in a smaller demo app to make it easier for us to track down?

A bit of digging around and I've discovered this only happens in services where I've used the private routing service: routing: service('-routing').

Replacing it with router: service() fixes my issue but is there anywhere this is documented? I was under the impression the public router service was still to come.

@artcommacode yes, it was announced in the post about the 2.15 release

Closing this then.

Thank you!

Was this page helpful?
0 / 5 - 0 ratings