AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Edge Function Deploy Returns Opaque 500 Due To Top-Level Bootstrap Error (Generate-Lesson)

Supabase CLI 2.76.15 and edge-runtime 1.73.3 fail deploy for function 'generate-lesson' after successful uploads. The failure is deterministic for this function's 740-line body, but a stub or similar function succeeds. The body likely performs top-level asynchronous work before Deno.serve, causing a bootstrap error that the platform masks as a 500 without logs.

highConfidence 72%Supabase-Edge-FunctionsPostgreSQLStorageRealtimeAffected Vsupabase-Cli 2.76.15Affected Vsupabase-Edge-Runtime 1.73.3

Origin Analysis

The function module likely executes top-level async/side-effectful code (e.g., await, initializing clients, fetching config) before registering the Deno.serve handler. During edge-runtime provisioning, this top-level code fails or times out, aborting bootstrap. The Supabase deploy pipeline does not propagate this bootstrap exception to function logs and returns a generic 'internal error' 500. This is a design/ops flaw: bootstrap errors are not surfaced, and module-scope awaits are not validated.
1. Run `npx supabase@2.76.15 functions deploy generate-lesson --no-verify-jwt --project-ref cmrhpmvjmbhzlpfhqzgw`. 2. Observe all asset uploads succeed, then final line returns `unexpected deploy status 500: {"message":"Function deploy failed due to an internal error"}`. 3. Repeat with a minimal `Deno.serve(() => new Response("ok"))` body: deploy succeeds. 4. Repeat with the same imports but trivial handler: deploy succeeds. 5. Restore original 740-line body: deploy fails 500 again.

Fixing Code Block

Edge Case Audit

If the real cause is a server-side bundler syntax error (e.g., unsupported TypeScript feature), this lazy-init pattern may not resolve the 500. In that case, use an esbuild pre-bundle step to output plain JavaScript and deploy that instead. Lazy initialization changes timing: the first request will wait for init and may experience higher latency; add a timeout and cache to avoid duplicate work. Test locally with `supabase functions serve` to ensure no top-level side effects remain. Rollback by restoring the original index.ts file.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state