emberjs / emberjs/ember.js

Cannot read property 'name' of undefined when trying to set queryParams in beforeModel

Open
#17,118 21 comments 9 reactions 0 assignees View on GitHub
Has Reproduction Query Params Routing
Dominant language
TypeScript
Stars
22.6k
Forks
4.2k
Avg merge
3d 12h
Merged PRs (30d)
15

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.