Merge pull request #1536 from magnusleo/fix-xhr-abort-error

Fix request abort error
This commit is contained in:
Leo Horie 2017-01-13 08:21:27 -05:00 committed by GitHub
commit c8ab6d1177

View file

@ -70,7 +70,9 @@ module.exports = function($window, Promise) {
if (typeof args.config === "function") xhr = args.config(xhr, args) || xhr
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
// 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))
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {