feat: max retries for failure
This commit is contained in:
@@ -8,9 +8,12 @@ import { readFile } from "../storage";
|
|||||||
interface GoogleSheetUpdateTask {
|
interface GoogleSheetUpdateTask {
|
||||||
name: string;
|
name: string;
|
||||||
runId: string;
|
runId: string;
|
||||||
status: 'pending' | 'completed';
|
status: 'pending' | 'completed' | 'failed';
|
||||||
|
retries: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MAX_RETRIES = 5;
|
||||||
|
|
||||||
export let googleSheetUpdateTasks: { [runId: string]: GoogleSheetUpdateTask } = {};
|
export let googleSheetUpdateTasks: { [runId: string]: GoogleSheetUpdateTask } = {};
|
||||||
|
|
||||||
|
|
||||||
@@ -103,6 +106,12 @@ const processGoogleSheetUpdates = async () => {
|
|||||||
console.log(`Successfully updated Google Sheets for run ${task.runId}`);
|
console.log(`Successfully updated Google Sheets for run ${task.runId}`);
|
||||||
delete googleSheetUpdateTasks[runId];
|
delete googleSheetUpdateTasks[runId];
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
if (task.retries < MAX_RETRIES) {
|
||||||
|
googleSheetUpdateTasks[runId].retries += 1;
|
||||||
|
} else {
|
||||||
|
// Mark as failed after maximum retries
|
||||||
|
googleSheetUpdateTasks[runId].status = 'failed';
|
||||||
|
}
|
||||||
console.error(`Failed to update Google Sheets for run ${task.runId}:`, error);
|
console.error(`Failed to update Google Sheets for run ${task.runId}:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user