diff --git a/supabase/functions/ai-generate-plan/index.ts b/supabase/functions/ai-generate-plan/index.ts index f370b75..f98a22e 100644 --- a/supabase/functions/ai-generate-plan/index.ts +++ b/supabase/functions/ai-generate-plan/index.ts @@ -19,6 +19,13 @@ type NivelType = type TipoCicloType = Database["public"]["Tables"]["planes_estudio"]["Insert"]["tipo_ciclo"]; +addEventListener("beforeunload", (ev: any) => { + // ev.detail.reason te dirá si es "timeout", "memory_limit" o "idle" + console.error("ALERTA: La función se va a apagar. Razón:", ev.detail?.reason); + + // Aquí puedes intentar un último log antes de que todo muera +}); + Deno.serve(async (req: Request): Promise => { const url = new URL(req.url); const functionName = url.pathname.split("/").pop(); diff --git a/supabase/functions/ai-generate-subject/index.ts b/supabase/functions/ai-generate-subject/index.ts index a2f5818..175cb58 100644 --- a/supabase/functions/ai-generate-subject/index.ts +++ b/supabase/functions/ai-generate-subject/index.ts @@ -9,6 +9,13 @@ import { type StructuredResponseOptions, } from "../_shared/openai-service.ts"; +addEventListener("beforeunload", (ev: any) => { + console.error( + "ALERTA: La función se va a apagar. Razón:", + ev?.detail?.reason, + ); +}); + /** * JSON input signature (when `Content-Type: application/json`) * diff --git a/supabase/functions/create-chat-conversation/index.ts b/supabase/functions/create-chat-conversation/index.ts index f06bc58..6057960 100644 --- a/supabase/functions/create-chat-conversation/index.ts +++ b/supabase/functions/create-chat-conversation/index.ts @@ -22,6 +22,13 @@ type AddMessageBody = { const app = new Hono(); +addEventListener("beforeunload", (ev: any) => { + console.error( + "ALERTA: La función se va a apagar. Razón:", + ev?.detail?.reason, + ); +}); + // Preflight CORS app.options( "*", diff --git a/supabase/functions/generate-subject-suggestions/index.ts b/supabase/functions/generate-subject-suggestions/index.ts index a6f1eb5..bb17975 100644 --- a/supabase/functions/generate-subject-suggestions/index.ts +++ b/supabase/functions/generate-subject-suggestions/index.ts @@ -10,6 +10,13 @@ import { type StructuredResponseOptions, } from "../_shared/openai-service.ts"; +addEventListener("beforeunload", (ev: any) => { + console.error( + "ALERTA: La función se va a apagar. Razón:", + ev?.detail?.reason, + ); +}); + export type DataAsignaturaSugerida = { nombre: Tables<"asignaturas">["nombre"]; codigo?: Tables<"asignaturas">["codigo"];