Fix 5982 - Do fetch after route change is complete#7076
Fix 5982 - Do fetch after route change is complete#7076Bargs merged 3 commits intoelastic:masterfrom
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
| self.fetch(); | ||
| }), | ||
|
|
||
| $rootScope.$on('$routeChangeSuccess', function () { |
There was a problem hiding this comment.
can you swap these event handlers so that start comes before success?
There was a problem hiding this comment.
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
$evalAsyncto schedule the query string replacement in the next tick, it simply does the replacement after the route change is complete based on therouteChangeSuccessevent.