supabase EdgeRuntime.waitUntil: Background Tasks That Finish

supabase EdgeRuntime.waitUntil lets your edge function return a response immediately while background work keeps running. Here is the pattern, ephemeral storage rules, WebSocket auth, and the limits to design around.

<!-- BRIEF SPEC (supabase-edge-functions-background-tasks-websockets) Variant: DEEP-GUIDE | Hook: DIRECT-ANSWER | FAQ: 6 | ~1600-2300 words Cover style: DARK-NEON (deep-guide) — dark navy, neon cyan+magenta; abstract 3D waveform made of connected socket lines radiating from a central function node. Distinct shape from the log-drains cover. No text. In-body images (2): (1) sequence diagram: client -> edge function -> immediate response, with waitUntil background task continuing after the response; (2) architecture diagram of a WebSocket edge function with JWT auth, fan-out to connected sockets, and the per-isolate limit. SERP Step 0: official launch blog + dev.to mirrors + one fresh skill doc with real WS/waitUntil patterns; no tutorial combines waitUntil + ephemeral storage + WS auth + limits with runnable code. Gap: the full pattern set, the per-isolate fan-out caveat, and a waitUntil vs queues table. --> Last updated: 2026-10-10 Yes — EdgeRuntime.waitUntil() runs your code after the HTTP response has been returned to the client. You call it inside your edge function handler with a promise, return the response immediately, and Supabase keeps the isolate alive until the background work settles (or hits the background time limit). It is the sanctioned way to do post-response work: sending the welcome email after signup, generating embeddings for a just-uploaded document, or fanning out a notification without making the user stare at a spinner. The rest of this guide shows the pattern done right, the two sibling features that ship with it (ephemeral storage and WebSockets), and the limits that decide whether waitUntil is enough or you need a real queue. What you will build: three patterns on one edge function runtime A post-response background task with…

Explore