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
router.replaceWith calls pushState on the history object with refreshModel QP #18416
Comments
#5566 may also be related |
As recommended in #5566 (comment), I'm able to solve the issue by using the private |
Converting to a native class in the route seems to break this workaround, so I might be back at square 1. |
I noticed something similar in my app (it could the exact same issue but it's a little hard to tell) I put together a Twiddle that shows the problem we are facing https://ember-twiddle.com/39fe48997dd6e62f6381e89d3c6aa74c?openFiles=routes.first.index%5C.js%2C Essentially, the flow of the logic is
I would expect that the browser's history receives a single However, what actually happens is that an intermediary URL is pushed into the browser with |
This is still happening as of Ember 3.20.4.
For our users, it means that they get stuck in a loop where they are unable to use the Back button anymore; doing do only removes the query param from the URL, which then re-enters the logic that calls I'm going to take a stab at adding a failing test to the Ember codebase for this. |
sentry: Ignore `TransitionAborted` errors According to emberjs/ember.js#18416 it looks like changing query params that have `refreshModel: true` causes an internal `TransitionAborted` error. This error is being ignored by Ember itself (see https://github.com/emberjs/ember.js/blob/v3.21.3/packages/`@ember/-internals/runtime/lib/ext/rsvp.js#L40-L42),` but Sentry also hooks into `RSVP.on('error')` and unfortunately reports these false positives (see emberjs/ember.js#12505) This PR actively ignores `TransitionAborted` errors in the `beforeSend()` hook of Sentry. r? `@jtgeibel`
Hi! We had the same issue recently but not with query-params. We are using the replaceWith methods to make a feature with sub-routes feels like it is only one history entry, hence playing with the replace to navigate.
Also, seems like it could be related to what's written in the documentation (page is preventing-and-retrying-transitions):
To prevent the pushState, we found a workaround to abort the browser-triggered transition, and create a new one right away from Ember... And then the replaceWith works as intended. |
Just ran into this issue on a big production app. Its definitely something that customers can encounter, exactly like @alexlafroscia described above over a year ago |
https://github.com/mehulkar/ember-example-replace-push-state
I think this may have the same root cause as #15801, but it manifests differently.
Problem
If a queryParam is configured to
refreshModel: true
, calls torouter.replaceWith
end up callingpushState
on history instead ofreplaceState
.I'm not totally sure how this would manifest as a "bug" in a browser for an end user, but in my case, I have a custom
Location
using a customhistory
object, and callingpushState
when we really meant to replace causes it to get an extra entry history entry.Debugging
It seems that Ember (or underlying
router.js
lib thinks that because of the queryParams refreshModel config, this replaceWith transition is invalid, and it cancels it and generates its own.Because router.replaceWith is implemented like this:
the
transitionTo()
promise gets replaced, and all the async stuff that causes the URL to update happens on the new promise, which does not yet have theurlMethod
set toreplace
.One possible solution here is that instead of using
transitionTo()
, aTransition
object should be constructed withurlMethod
set as part of the constructor, so that it does the right thing throughout its lifecycle, but that seems like a really big change.The text was updated successfully, but these errors were encountered: