-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Redirecting a transition to same route with different query params does not work unless transition is aborted before #18577
Comments
@jelhan which version of Ember are you seeing this in? |
@acorncom I'm quite sure that I had reproduced it using the latest version of Ember at the same day when reporting. So I think it was 3.14.1. But I was also able to reproduce it with latest ember-source available today, which is 3.16.0. I created a repository with the reproduction mentioned above: https://github.com/jelhan/ember-demo-redirect-to-same-route-with-different-query-params Here are the steps to reproduce both issues mentioned above using that repo. Assuming that you have cloned it, installed dependencies and run 1. transition to route triggering the redirect from another route
Expected:
Actual:
2. open that route directlySee an error been thrown and nothing rendered. The error is:
Fixing the error by aborting the transitionTo reproduce that aborting the transition before doing the redirect fixes both issues uncomment these line: https://github.com/jelhan/ember-demo-redirect-to-same-route-with-different-query-params/blob/1326804684273b9369725099f36f262fabdd9832/app/routes/foo.js#L6-L7 |
I have what appears to be an additional variant of this, available in this repo. If you try to do a To see the reproduction behavior and how it varies for later entries, comment out these lines: later transitions work fine; only the first transition into the route fails this way. To see that |
@chriskrycho I think I just ran into the bug you're describing, but want to confirm. |
Fixed! I accidentally made a private repo. Should be visible now! |
Same...Here is my repo.
|
Cross-posting #11563 (comment):
|
I updated my reproduction repository to Ember 3.22. Can still reproduce the bug with that latest stable release. The error message thrown in the second case changed a little bit. It's now: The full stack trace to help people finding this issue with Google:
I applied @buschtoens patch. This resolves the original bug but reveals another one: The |
@jelhan I've seen the same error while working on an issue related to disappearing QP's! |
@rreckonerr If I got it right you suspect that the bug was introduced by tildeio/router.js@f385d11. It was released in Ember.js upgraded to
Line 149 in a5f870f
[email protected] as using [email protected] : Line 139 in abf753a
Will try to find some time to verify that the bug is reproducible with |
I am experiencing the same issue where an exception is thrown when the application is loaded on the route which is transitioning only to change the query-params. It's a very simple reproduction in 3.22: https://github.com/kmccullough/ember-default-query-param |
@kmccullough Thanks for this example :) @jelhan There is no more error with the last changes, but the behavior is still inccorrect, I mean the qp update is not reflected in the URL. I'll try to investigate. Thanks to the works done by @alexlafroscia and @buschtoens maybe this will be resolved. |
I'm seeing this in ember 3.26.1 as well. |
Same problem as @chriskrycho with ember 3.22. Also cannot use |
We're still seeing this issue in Ember.js 5.1. If we're replacing a route with the same route but different query params: export default class PortfolioRoute extends Route {
beforeModel() {
this.router.replaceWith('portfolio', {
queryParams: {
bla: 'bla'
}
});
}
} the route crashes on first render with:
Unfortunately none of the workarounds seem to work. Any suggestions on getting around the bug? |
same problem in my project. any suggestions ??? |
Just encountered this on Ember 4.12. 😞 @buschtoens fix in tildeio/router.js#307 does seem to fix it for me, though. Pretty amazed this has gone so long without being addressed since it seems like a common scenario. Anyone know of any workarounds or any way this could be monkey-patched? |
@seanCodes I have been investigating this bug and also found that if i was trying to transition multiple times it would also trigger e.g.
By adding returning on transition it stopped the error.
Maybe this might help in your case? |
I'm seeing two weird bugs if doing a redirect to the same route with different queryParams in
beforeModel
hook:<LinkTo>
ortransitionTo()
, the query param is not reflected in the URL.The error thrown is this one:
It's caused by
routeInfos
oftransition
being an empty array here: https://github.com/emberjs/ember.js/blob/v3.14.1/packages/%40ember/-internals/routing/lib/system/route.ts#L2523_queryParamsFor
can't handle that case and throws at this line: https://github.com/emberjs/ember.js/blob/v3.14.1/packages/%40ember/-internals/routing/lib/system/router.ts#L926For a minimal reproduction use this code:
The current route is logged in template to verify that the query params are available on
RouteInfo
object for scenario 1. And they are indeed. They are just not represented in URL.Both bugs could be fixed by explicitly aborting the transition before doing the redirect:
But accordingly to documentation
transitionTo()
should implicitly abort the transition. It should not be required to do it manually. Also if this is the recommended solution, there should be an assertion if the transition is not aborted before. It should not end with a broken state (URL not reflecting query parameters in URL) neither with throwing aTypeError
.There are some issues which seem to be related but slightly different:
The text was updated successfully, but these errors were encountered: