-
Notifications
You must be signed in to change notification settings - Fork 8.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
Fix 5982 - Do fetch after route change is complete #7076
Conversation
Oh snap, hope this fixes it! Will take a look soon |
I hope so too! Some design changes in add data have really made this important. The only thing I'm not sure of is if there are any unintended side effects, but I played around with it some and didn't notice any issues. The one test failure simply asserts that the state object gets destroyed on $routeChangeStart. There's no description why in the commit message though. Looks like @w33ble added the test so he might have some insight into how safe this change is as well. |
If it's not safe to destroy the state in $routeChangeSuccess, I can always create an additional handler for the fetch and leave the destroy action in its current handler. |
Man, that was a long time ago. Back when I had even less of an idea what I was doing than I have now ;) I suspect I was just trying to make sure that the appState was being cleaned up, not specifically that it was being cleaned up during that event. I think it's safe to update the test to |
^ this |
…ntended side effects
@@ -24,12 +24,16 @@ export default function StateProvider(Private, $rootScope, $location) { | |||
self.fetch(); | |||
}), | |||
|
|||
$rootScope.$on('$routeChangeSuccess', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you swap these event handlers so that start comes before success?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your wish is my command :)
Updated.
LGTM! Now to figure out how far back we should backport this... |
Good point, @epixa what's our policy on backporting now? |
I wouldn't bother backporting it. The bug has been around for awhile and is a P2. As you pointed out, it's really only a bigger deal now because of the add data ui, which is 5.0+. |
Works for me. |
Fixes #5982
Fixes #5986
@spalger summed up the root cause of the issue well in #6788:
This PR takes the same approach, but instead of using undefined behavior in
$evalAsync
to schedule the query string replacement in the next tick, it simply does the replacement after the route change is complete based on therouteChangeSuccess
event.