emberjs / ember.js

Ember.js - A JavaScript framework for creating ambitious web applications
https://emberjs.com
MIT License
22.45k stars 4.21k forks source link

Router `transition.retry` with dynamic segments and `refreshModel` queryParams causes unexpected error #16992

Open rafaelbnp opened 6 years ago

rafaelbnp commented 6 years ago

Seems related to #10945.

My use case is: when a user tries to navigate with an expired token (by leaving the window open long enough) the API calls will fail with a unauthorized error. We added some logic to the Applications's error action to catch this type of error, re-authenticate the user and retry the transition after the authentication. The problem is that when I try to transition.retry() to a route with dynamic segments and query parameters with refreshModel, it will fail with the below error:

You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route [route name]

If I set my query param to refreshModel: false, it works fine.

Here's a reproducible twiddle: https://ember-twiddle.com/e25fc434b6e1c1627e553b8120203655?openFiles=routes.dynamic-segment.js%2C You can see the error when clicking on the 'Dynamic segment with query param' link. If you change the refreshModel to false on /routes/dynamic-segment.js it works.

Any help is appreciated. Thanks!

tpetrone commented 5 years ago

I am experiencing something similar when trying to transition.retry() a Transition that was triggered by a Route.refresh() where queryParamsOnly: true

I guess this is somehow related to #16921

krukid commented 3 years ago

I find that Route#refresh() produces a transition that cannot be retried if there are dynamic segments.

Here's my use case: https://ember-twiddle.com/6d2f981f6628a3260db8cafd3b3aac0a?openFiles=routes.flopping-route%5C.js%2C

rwjblue commented 3 years ago

@krukid - The issue you mention seems somewhat unrelated to the original one being discussed here (I think). Would you mind filing a new issue for that?

@rreckonerr recently fixed a somewhat related bug (where we would not thread through the original values when doing intermediate transitions), this seems somewhat related. I think the first step here would be to make a failing test case over in router.js...