Skip to content

Commit

Permalink
fix: fix unhandledRejection (#952)
Browse files Browse the repository at this point in the history
* fix: unhandledRejection
  • Loading branch information
sbansla committed Aug 10, 2023
1 parent 73ddddd commit b7c5598
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions src/base/Version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,32 +311,33 @@ export default class Version {
return;
}

promise.then((page: any) => {
try {
page.instances.forEach(function (instance: any) {
if (
done ||
(typeof params.limit !== "undefined" &&
currentResource >= params.limit)
) {
done = true;
return false;
}
currentResource++;
callback?.(instance, onComplete);
});
} catch (e) {
return onComplete(e);
}

if (!done) {
currentPage++;
fetchNextPage(page.nextPage.bind(page));
} else {
onComplete();
}
});
promise.catch(onComplete);
promise
.then((page: any) => {
try {
page.instances.forEach(function (instance: any) {
if (
done ||
(typeof params.limit !== "undefined" &&
currentResource >= params.limit)
) {
done = true;
return false;
}
currentResource++;
callback?.(instance, onComplete);
});
} catch (e) {
return onComplete(e);
}

if (!done) {
currentPage++;
fetchNextPage(page.nextPage.bind(page));
} else {
onComplete();
}
})
.catch(onComplete);
}

return new Promise((resolve, reject) => {
Expand Down

0 comments on commit b7c5598

Please sign in to comment.