Fix: Address HMR failures and Fast Refresh incompatibility

This commit is contained in:
gpt-engineer-app[bot]
2025-10-21 13:13:10 +00:00
parent 0d247d9fdd
commit 827f0f8ea5
8 changed files with 280 additions and 76 deletions

View File

@@ -12,7 +12,13 @@ const TOPICS = {
MODERATION_REPORTS: 'moderation-reports',
} as const;
// Simple request tracking
const startRequest = () => ({ requestId: crypto.randomUUID(), start: Date.now() });
const endRequest = (tracking: { start: number }) => Date.now() - tracking.start;
serve(async (req) => {
const tracking = startRequest();
if (req.method === 'OPTIONS') {
return new Response(null, { headers: corsHeaders });
}
@@ -91,29 +97,41 @@ serve(async (req) => {
});
}
console.log('Sync completed:', results);
const duration = endRequest(tracking);
console.log('Sync completed:', results, { requestId: tracking.requestId, duration });
return new Response(
JSON.stringify({
success: true,
message: 'Moderator sync completed',
results,
requestId: tracking.requestId
}),
{
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
headers: {
...corsHeaders,
'Content-Type': 'application/json',
'X-Request-ID': tracking.requestId
},
status: 200,
}
);
} catch (error: any) {
console.error('Error syncing moderators to topics:', error);
const duration = endRequest(tracking);
console.error('Error syncing moderators to topics:', error, { requestId: tracking.requestId, duration });
return new Response(
JSON.stringify({
success: false,
error: error.message,
requestId: tracking.requestId
}),
{
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
headers: {
...corsHeaders,
'Content-Type': 'application/json',
'X-Request-ID': tracking.requestId
},
status: 500,
}
);