FIX: Avoid error on ajax.abort() when client has not opened the request.

FIX: Avoid error on ajax.abort() when client has not opened the request.

diff --git a/app/assets/javascripts/discourse/lib/ajax.js.es6 b/app/assets/javascripts/discourse/lib/ajax.js.es6
index dc81ce6..3420777 100644
--- a/app/assets/javascripts/discourse/lib/ajax.js.es6
+++ b/app/assets/javascripts/discourse/lib/ajax.js.es6
@@ -105,6 +105,8 @@ export function ajax() {
     };
 
     args.error = (xhr, textStatus, errorThrown) => {
+      // 0 represents the `UNSENT` state
+      if (xhr.readyState === 0) return;
       handleLogoff(xhr);
 
       // note: for bad CSRF we don't loop an extra request right away.

GitHub sha: a6d93f63

Iā€™m curious: when does that happen exactly?

@sam was hitting it regularly when aborting a search.

1 Like