Skip to content

Commit

Permalink
More fixes for loadXXX retry logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
mramato committed Jan 19, 2018
1 parent 508a22b commit fe92f99
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
8 changes: 6 additions & 2 deletions Source/Core/loadImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,20 @@ 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) {
// Reset request so it can try again
request.state = RequestState.UNISSUED;
request.deferred = undefined;

return makeRequest(resource);
return makeRequest(resource, allowCrossOrigin);
}

return when.reject(e);
});
});
Expand Down
29 changes: 14 additions & 15 deletions Source/Core/loadJsonp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
}

Expand Down
28 changes: 14 additions & 14 deletions Source/Core/loadWithXhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
}

Expand Down

0 comments on commit fe92f99

Please sign in to comment.