Skip to content

Commit

Permalink
fix: clear pending root if detected on push
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Nov 30, 2023
1 parent e280c9a commit fd12c15
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/datalayer/persistance.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ const clearPendingRoots = async (storeId) => {
const data = response.body;

if (data.success) {
return data.mirrors;
return true;
}

logger.error(`FAILED GETTING MIRRORS FOR ${storeId}`);
return [];
logger.error(`Unable to clear pending root for ${storeId}`);
return false;
} catch (error) {
logger.error(error);
return [];
return false;
}
};

Expand Down Expand Up @@ -432,10 +432,13 @@ const pushChangeListToDataLayer = async (storeId, changelist) => {

if (data.error.includes('Key already present')) {
logger.info('Pending root detected, waiting 5 seconds and retrying');
await clearPendingRoots(storeId);
attempts++;
await new Promise((resolve) => setTimeout(resolve, 5000));
continue; // Retry
const rootsCleared = await clearPendingRoots(storeId);

if (rootsCleared) {
attempts++;
await new Promise((resolve) => setTimeout(resolve, 5000));
continue; // Retry
}
}

logger.error(
Expand Down

0 comments on commit fd12c15

Please sign in to comment.