mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 09:11:13 -05:00
feat: Implement retry logic and tracking
This commit is contained in:
@@ -284,14 +284,23 @@ export function useModerationActions(config: ModerationActionsConfig): Moderatio
|
||||
}
|
||||
}
|
||||
|
||||
const { data, error, requestId } = await invokeWithTracking(
|
||||
const { data, error, requestId, attempts } = await invokeWithTracking(
|
||||
'process-selective-approval',
|
||||
{
|
||||
itemIds: submissionItems.map((i) => i.id),
|
||||
submissionId: item.id,
|
||||
},
|
||||
config.user?.id
|
||||
config.user?.id,
|
||||
undefined,
|
||||
undefined,
|
||||
30000, // 30s timeout
|
||||
{ maxAttempts: 3, baseDelay: 1500 } // Critical operation - retry config
|
||||
);
|
||||
|
||||
// Log if retries were needed
|
||||
if (attempts && attempts > 1) {
|
||||
logger.log(`Approval succeeded after ${attempts} attempts for ${item.id}`);
|
||||
}
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
@@ -620,14 +629,22 @@ export function useModerationActions(config: ModerationActionsConfig): Moderatio
|
||||
|
||||
failedItemsCount = failedItems.length;
|
||||
|
||||
const { data, error, requestId } = await invokeWithTracking(
|
||||
const { data, error, requestId, attempts } = await invokeWithTracking(
|
||||
'process-selective-approval',
|
||||
{
|
||||
itemIds: failedItems.map((i) => i.id),
|
||||
submissionId: item.id,
|
||||
},
|
||||
config.user?.id
|
||||
config.user?.id,
|
||||
undefined,
|
||||
undefined,
|
||||
30000,
|
||||
{ maxAttempts: 3, baseDelay: 1500 } // Retry for failed items
|
||||
);
|
||||
|
||||
if (attempts && attempts > 1) {
|
||||
logger.log(`Retry succeeded after ${attempts} attempts for ${item.id}`);
|
||||
}
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
@@ -699,16 +716,24 @@ export function useModerationActions(config: ModerationActionsConfig): Moderatio
|
||||
onActionStart(item.id);
|
||||
|
||||
try {
|
||||
// Call edge function for email notification
|
||||
const { error: edgeFunctionError, requestId } = await invokeWithTracking(
|
||||
// Call edge function for email notification with retry
|
||||
const { error: edgeFunctionError, requestId, attempts } = await invokeWithTracking(
|
||||
'send-escalation-notification',
|
||||
{
|
||||
submissionId: item.id,
|
||||
escalationReason: reason,
|
||||
escalatedBy: user.id,
|
||||
},
|
||||
user.id
|
||||
user.id,
|
||||
undefined,
|
||||
undefined,
|
||||
45000, // Longer timeout for email sending
|
||||
{ maxAttempts: 3, baseDelay: 2000 } // Retry for email delivery
|
||||
);
|
||||
|
||||
if (attempts && attempts > 1) {
|
||||
logger.log(`Escalation email sent after ${attempts} attempts`);
|
||||
}
|
||||
|
||||
if (edgeFunctionError) {
|
||||
// Edge function failed - log and show fallback toast
|
||||
|
||||
Reference in New Issue
Block a user