Skip to content

Commit

Permalink
Add a failAction for posts scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Apr 10, 2024
1 parent 83b7a35 commit 0a42807
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions assets/js/scan-posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ const progressPlannerTriggerScan = () => {
progressPlannerTriggerScan();
};

const failAction = ( response ) => {
// If the window.progressPlannerFailScanCount is not defined, set it to 1.
if ( ! window.progressPlannerFailScanCount ) {
window.progressPlannerFailScanCount = 1;
} else {
window.progressPlannerFailScanCount++;
}

// If the scan has failed more than 10 times, stop retrying.
if ( window.progressPlannerFailScanCount > 10 ) {
return;
}

console.warn( 'Failed to scan posts. Retrying...' );
console.log( response );
// Retry after 200ms.
setTimeout( progressPlannerTriggerScan, 200 );
}

/**
* The AJAX request to run.
*/
Expand Down

0 comments on commit 0a42807

Please sign in to comment.