Skip to content

Commit

Permalink
Fixes liferay#1330 - Fixes the request retries logic
Browse files Browse the repository at this point in the history
  • Loading branch information
matuzalemsteles committed Dec 4, 2018
1 parent d2a553f commit cba5eaf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/clay-data-provider/src/ClayDataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class ClayDataProvider extends ClayComponent {
* @protected
*/
_setRequestRetries(err, requestRetries) {
if (this.requestRetries > 0 && requestRetries > this.requestRetries) {
if (this.requestRetries > 0 && requestRetries < this.requestRetries) {
console.error(
`DataProvider: (${requestRetries}/${
`DataProvider: (${requestRetries + 1}/${
this.requestRetries
}) Request attempt failed`,
err
Expand Down Expand Up @@ -137,7 +137,7 @@ class ClayDataProvider extends ClayComponent {
*/
filter(query, extract = elem => elem) {
if (!this._isResolvedData) {
return;
return [];
}

return this._dataSource
Expand Down
11 changes: 5 additions & 6 deletions packages/clay-data-provider/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,14 @@ export const timeout = (ms, promise) => {
const timeoutId = setTimeout(() => {
reject(new Error('timeout'));
}, ms);
promise.then(
res => {
promise
.then(res => {
clearTimeout(timeoutId);
resolve(res);
},
err => {
})
.catch(err => {
clearTimeout(timeoutId);
reject(err);
}
);
});
});
};

0 comments on commit cba5eaf

Please sign in to comment.