@sgiehl @tsteur luckily our
ajaxHelper.js collects all ajax requests into an array and we already have an
abort method for it:
So I added one more line to call this method on every reporting page load. I tested it locally and it did the job.
This might also be related to https://github.com/matomo-org/matomo/issues/10578
This might also be related to #10578
@Findus23 yes, there is a chance it solves that as well. I try to reproduce the other issue without the modifications and then with this PR.
Update: I see now, the other issue is different. In this PR we just abort the ajax requests when we change reporting page. The other issue happens with a full page reload: the new page starts loading but the browser still shows the original page, which has an error now, because the request are not loading anymore.
One solution for that one could be to delay that notification message a little bit, that time should be enough to the browser to load the new page.
I updated the PR, because I find out where is that error on dashboard coming from #10578.
I added 2sec timeout for showing that error message. In this way, if the user stays on the page and an error occurs, will see it anyway, but if we clicking away from the page, the browser will have time to start loading the other page, before the error message shows up.
I haven't tested this yet, but for the second issue, would it also work to cancel ajax requests in the window's
beforeunload events? If that would work, the solution wouldn't depend on a timeout which might avoid edge cases where it takes a long time for the next page to start loading.
Hi @diosmosis, I modified the PR. Instead of using a timeout, I'm checking if the
aborted. If it's
aborted, the error is not shown.