Skip to content

Commit

Permalink
feat: add some error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Oct 17, 2023
1 parent 5a56ecb commit 7833846
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/datalayer/syncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,21 @@ const getRootDiff = (storeId, root1, root2) => {
};

const getStoreData = async (storeId, callback, onFail, retry = 0) => {
logger.info(`Getting store data, retry: ${retry}`);
if (retry <= 10) {
const encodedData = await dataLayer.getStoreData(storeId);
if (_.isEmpty(encodedData?.keys_values)) {
await new Promise((resolve) => setTimeout(() => resolve(), 120000));
return getStoreData(storeId, callback, onFail, retry + 1);
try {
logger.info(`Getting store data, retry: ${retry}`);
if (retry <= 10) {
const encodedData = await dataLayer.getStoreData(storeId);
if (_.isEmpty(encodedData?.keys_values)) {
await new Promise((resolve) => setTimeout(() => resolve(), 120000));
return getStoreData(storeId, callback, onFail, retry + 1);
} else {
callback(decodeDataLayerResponse(encodedData));
}
} else {
callback(decodeDataLayerResponse(encodedData));
onFail();
}
} else {
} catch (error) {
logger.error(error.message);
onFail();
}
};
Expand Down

0 comments on commit 7833846

Please sign in to comment.