Skip to content
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

Infinite recursion with willTransition hook and queryParams #9818

Open
kekbur opened this issue Dec 5, 2014 · 6 comments
Open

Infinite recursion with willTransition hook and queryParams #9818

kekbur opened this issue Dec 5, 2014 · 6 comments
Assignees

Comments

@kekbur
Copy link

kekbur commented Dec 5, 2014

I have a route with a query parameter with refreshModel set to true. The route has a willTransition hook, which prompts the user to confirm that they want to navigate away from the route. If the user presses cancel, the transition is aborted using transition.abort(). This combination causes the router to enter infinite recursion where the user is presented with the confirm dialog over and over again until they press ok.

JSbin: http://jsbin.com/vuzaxe/1
Steps to reproduce: click one of the colors, press the cancel button on the confirmation dialog

@Serabe
Copy link
Member

Serabe commented Mar 9, 2017

Marking issue a inactive as per our triage policy.

@btecu
Copy link
Contributor

btecu commented Apr 26, 2018

Issue still present on 3.1.1: https://github.com/btecu/ember-issues/tree/9818
Might be related with #5210.

@karthiicksiva
Copy link
Contributor

karthiicksiva commented Jun 5, 2018

Same as #12473

Update: For my case, i ended up adding !transition.queryParamsOnly for showing the confirmation modal.

@pixelhandler
Copy link
Contributor

This is a Bug there are workarounds like @karthiicksiva mentions. Or even better, if you really need to transition to the same state/route but with different params maybe ask the question "why am I using the same state of the app for a different state?" Likely using a different route would be even better.

@pixelhandler
Copy link
Contributor

@karthiicksiva I just noticed that transition.queryParamsOnly is not part of the documented API, https://emberjs.com/api/ember/release/classes/Transition only mentions abort() and retry().

@rwjblue what do you think about making queryParamsOnly public on the Transition documentation?

@akashdsouza
Copy link

akashdsouza commented Aug 18, 2022

This issue is even more pronounced than I thought.

Or even better, if you really need to transition to the same state/route but with different params maybe ask the question "why am I using the same state of the app for a different state?" Likely using a different route would be even better.

It even shows up for different routes that have same query parameter values. Even after transition is aborted, the query param value from targetRoute is updated to current route which causes an infinite loop of queryParamDidChange calls until stack size exceeds. I'm seeing this error on version 3.28.

Twiddle reproduction: https://ember-twiddle.com/6cd2aa8a2605fa851397a83953e4ecb2?numColumns=2&openFiles=routes.my-route%5C.js%2Croutes.my-route-one%5C.js

Related issue: tildeio/router.js#323

sukima added a commit to sukima/ember-dirty-change-example that referenced this issue Sep 8, 2022
This reverts commit 813c9be.

I was very mistaken. The issue wasn't with my code but with versions of
Ember: emberjs/ember.js#9818
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants