From bfccd1b6bf8c4d53202fd9769d930b4bff3d7f24 Mon Sep 17 00:00:00 2001 From: Magnus Leo Date: Fri, 13 Jan 2017 09:29:28 +0100 Subject: [PATCH 1/2] Fix request abort error --- request/request.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request/request.js b/request/request.js index 123ae1e7..442777f9 100644 --- a/request/request.js +++ b/request/request.js @@ -70,7 +70,7 @@ module.exports = function($window, Promise) { if (typeof args.config === "function") xhr = args.config(xhr, args) || xhr xhr.onreadystatechange = function() { - if (xhr.readyState === 4) { + if (xhr.status && xhr.readyState === 4) { try { var response = (args.extract !== extract) ? args.extract(xhr, args) : args.deserialize(args.extract(xhr, args)) if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) { From a640eaeb44e297e9667e29ea4e015e822a7c2012 Mon Sep 17 00:00:00 2001 From: Magnus Leo Date: Fri, 13 Jan 2017 11:27:54 +0100 Subject: [PATCH 2/2] Comment why the request abort error happens --- request/request.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/request/request.js b/request/request.js index 442777f9..304673fc 100644 --- a/request/request.js +++ b/request/request.js @@ -70,6 +70,8 @@ module.exports = function($window, Promise) { if (typeof args.config === "function") xhr = args.config(xhr, args) || xhr xhr.onreadystatechange = function() { + // Don't throw errors on xhr.abort(). XMLHttpRequests ends up in a state of + // xhr.status == 0 and xhr.readyState == 4 if aborted after open, but before completion. if (xhr.status && xhr.readyState === 4) { try { var response = (args.extract !== extract) ? args.extract(xhr, args) : args.deserialize(args.extract(xhr, args))