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

Router redirects should not abort transactions #3056

Closed
wagenet opened this issue Jul 28, 2013 · 15 comments
Closed

Router redirects should not abort transactions #3056

wagenet opened this issue Jul 28, 2013 · 15 comments
Assignees
Labels

Comments

@wagenet
Copy link
Member

wagenet commented Jul 28, 2013

This means that even if the redirect is in the same tree we have to exit and re-enter all of the parents.

@stefanpenner
Copy link
Member

👍

@machty
Copy link
Contributor

machty commented Jul 28, 2013

This seems good. I guess this is how pre-facelift stuff worked, right?

@stefanpenner
Copy link
Member

On redirect, we should likely, fulfill with something that correctly conveys final resting point.

To support something like "abort" or "unauthorized", the rejection case may be valid. If that is decided, we may want to explore throwing specific routing errors (ala Router.ForbiddenError or Router.UnauthorizedError).

The key being, if we overload the rejections for both exceptional and flow control, we must still be able to distinguish the difference, and handle/swallow/report accordingly.

(@machty I edited my comment, hopefully it is slightly more coherent)

@ghost ghost assigned machty Jul 30, 2013
@machty
Copy link
Contributor

machty commented Jul 30, 2013

@stefanpenner i don't quite follow your comment about Router.Forbidden... say more?

@wagenet
Copy link
Member Author

wagenet commented Aug 23, 2013

@stefanpenner, @machty This seems like a big issue. What's the plan to address this?

@machty
Copy link
Contributor

machty commented Aug 23, 2013

As i mentioned in the call, this is a very blanket and not totally accurate issue, and many of the instances of this are already fixed. I need some more specific examples when this does not work (and there are some examples in other issues that I'll be working on over the next few days). But just so we're clear, it's not like this is the definite behavior for all transitions; afaik, there's just a few more corner cases to nail.

@wagenet
Copy link
Member Author

wagenet commented Oct 13, 2013

@machty, any more recent thoughts on this?

@machty
Copy link
Contributor

machty commented Nov 11, 2013

The latest on this is what I wrote here

@machty
Copy link
Contributor

machty commented Nov 29, 2013

I can say pretty confidently that this will entirely cease to be an issue with my router.js refactor.

@machty
Copy link
Contributor

machty commented Dec 29, 2013

This is megafixed via #4008

@machty machty closed this as completed Dec 29, 2013
@Bargs
Copy link

Bargs commented Aug 5, 2015

If this issue was fixed at some point, it seems like there might have been a regression. I've run into the same behavior described in #3163. I have a transitionTo the login page in my application route's model hook which conditionally fires if an ajax request says the user is unauthenticated. It's a fairly simple scenario without any query params or anything. On page load, the application route hooks get called twice, once on the initial transition and again after the first transition is aborted by redirecting to the login page.

The transition log looks like this:

DEBUG: -------------------------------
DEBUG: Ember      : 1.13.3
DEBUG: Ember Data : 1.13.5
DEBUG: jQuery     : 2.1.3
DEBUG: -------------------------------
Attempting URL transition to /
Preparing to transition from '' to ' index'
Transition #0: application: calling beforeModel hook
Transition #0: application: calling deserialize hook
Attempting transition to login
Transition #0: index: transition was aborted
Transition #1: application: calling beforeModel hook
Transition #1: application: calling deserialize hook
Transition #0: detected abort.
Attempting transition to login
Transition #1: application: calling afterModel hook
Transition #1: login: calling beforeModel hook
Transition #1: login: calling deserialize hook
Transition #1: login: calling afterModel hook
Transition #1: Resolved all models on destination route; finalizing transition.
Transitioned into 'login'
Transition #1: TRANSITION COMPLETE.

@msounthar
Copy link

@Bargs I am facing the same issue, Were you able to resolve it?

@Bargs
Copy link

Bargs commented Nov 6, 2015

I believe I had to work around it by saving a variable on the first load that I could conditionally check for to avoid taking actions on the second load. I don't work on this application anymore though so I don't know if it's been fixed in future versions.

@msounthar
Copy link

@Bargs Thanks!

@musterjunk
Copy link

I am seeing this behaviour on routes as well. env: on build cli 3.13.2 node 12.14.0 and os lunix x64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants