ember.js: Cannot read property 'name' of undefined when trying to set queryParams in beforeModel
I’m getting the error TypeError: Cannot read property 'name' of undefined when trying to this.transitionTo({ queryParams: { somParam: 'someValue' } }) in this very line: https://github.com/emberjs/ember.js/blob/bef860222ac1ce8b86c9e2ed129e24beb0c07132/packages/%40ember/-internals/routing/lib/system/router.ts#L1083
I debugged it and it appears that routeInfos is an empty array and therefore that line must throw naturally. As I am unable to reproduce it in a twiddle and have no clue how to debug this further, I’d like to know what an empty routeInfos array actually means here and if this is an error after all or rather a bug? When looking at my app, it works as expected, i.e. the query parameter does get set and the URL in the browser is updated accordingly. So this is not an issue about the query parameter not being set.
For the matter of this issue, I’d say a check if that array is empty and a better error message should be added. I can’t PR this as I don’t understand the internals here, otherwise I would.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 8
- Comments: 21 (8 by maintainers)
I’m getting this error as well when trying to
transitionin abeforeModelhook. UsingreplaceWithinstead oftransitionTostill throws the error. I’m transitioning to the same route, only with added query parameters. Using Ember 3.5I would say ‘maybe’ actually, because there is an other similar issue here (with the same symptoms): https://github.com/emberjs/ember.js/issues/11563 in which it seems like tildeio/router.js#303 is not enough 😦 But in any case we have to decide what to do with this router.js pr. And for now, I must admit I have no idea if this is good or not.