Repeated page reloads on request failures



I’ve been experiencing the case where my page within Electron reloads itself. This seems to occur each time a failure to load an item into the page. This can be an image that is requested locally but not present but also on XHR requests. The XHR requests are the real issue as missing images can just be fixed. Often those XHR requests are showing up as being aborted/cancelled almost immediately. The result of this is that the page just keeps looping. By adding an beforeunload handler I can block the repeated reloads, even though they are being attempted. By throttling the XHR requests I can reduce the number that get aborted/cancelled. The same code when run through Chrome as a conventional website does not experience this issue.

Has anyone had a similar experience or know why XHR requests are likely to get cancelled as I’m not calling cancel in my code?



Hi, does the app reload happen when an XHR succeeds? If not, and without seeing your code base, is it possible you have an event listener set up to check if a request fails which triggers an app reload?


Hi, only when the request fails does the reload occur. I’ve got a class that wraps all my XMLHttp requests and logs the abort to the console but I don’t initiate a page reload myself. The same class is used in Chrome but does not have the same effect, including the aborting of the XHR requests in the first place. It could be the reload that causes the aborts or the aborts causing the reload. Not sure how to prove which way round it is happening.


Does your app use ClientRequest anywhere? It seems that there may be a listener somewhere for an request.on('error') event that could be triggering this reload.

Under this hypothesis, the app will load once, come back with an error on the XHR and force reloads infinitely as it reloads the page and keeps getting request errors.


I’m not using ClientRequest, just XMLHttpRequest as I use the same code base in standard browser environment.