diff --git a/Source/Core/loadImage.js b/Source/Core/loadImage.js index 910d9690ef41..1427f6bc8ed8 100644 --- a/Source/Core/loadImage.js +++ b/Source/Core/loadImage.js @@ -106,6 +106,11 @@ define([ return promise .otherwise(function(e) { + //Don't retry cancelled or otherwise aborted requests + if (request.state !== RequestState.FAILED) { + return when.reject(e); + } + return resource.retryOnError(e) .then(function(retry) { if (retry) { @@ -113,9 +118,8 @@ define([ request.state = RequestState.UNISSUED; request.deferred = undefined; - return makeRequest(resource); + return makeRequest(resource, allowCrossOrigin); } - return when.reject(e); }); }); diff --git a/Source/Core/loadJsonp.js b/Source/Core/loadJsonp.js index 7ac867a717bf..65e3e4bc1d7a 100644 --- a/Source/Core/loadJsonp.js +++ b/Source/Core/loadJsonp.js @@ -123,22 +123,21 @@ define([ return promise .otherwise(function(e) { - if (request.state === RequestState.FAILED) { - return resource.retryOnError(e) - .then(function(retry) { - if (retry) { - // Reset request so it can try again - request.state = RequestState.UNISSUED; - request.deferred = undefined; - - return makeRequest(resource, callbackParameterName, functionName); - } - - return when.reject(e); - }); + if (request.state !== RequestState.FAILED) { + return when.reject(e); } - - return when.reject(e); + return resource.retryOnError(e) + .then(function(retry) { + if (retry) { + // Reset request so it can try again + request.state = RequestState.UNISSUED; + request.deferred = undefined; + + return makeRequest(resource, callbackParameterName, functionName); + } + + return when.reject(e); + }); }); } diff --git a/Source/Core/loadWithXhr.js b/Source/Core/loadWithXhr.js index 8f90d7d9b540..f7067be65f42 100644 --- a/Source/Core/loadWithXhr.js +++ b/Source/Core/loadWithXhr.js @@ -114,22 +114,22 @@ define([ return data; }) .otherwise(function(e) { - if ((request.state === RequestState.FAILED) && defined(optionsOrResource.retryOnError)) { - return optionsOrResource.retryOnError(e) - .then(function(retry) { - if (retry) { - // Reset request so it can try again - request.state = RequestState.UNISSUED; - request.deferred = undefined; - - return makeRequest(optionsOrResource); - } - - return when.reject(e); - }); + if ((request.state !== RequestState.FAILED) || !defined(optionsOrResource.retryOnError)) { + return when.reject(e); } - return when.reject(e); + return optionsOrResource.retryOnError(e) + .then(function(retry) { + if (retry) { + // Reset request so it can try again + request.state = RequestState.UNISSUED; + request.deferred = undefined; + + return makeRequest(optionsOrResource); + } + + return when.reject(e); + }); }); }