# waitUntil is not a queue, and pg_net is not one either > The three things people reach for to move work out of a web request are each missing a guarantee they are assumed to have. What the docs actually say about durability, dead letter queues, and picking a realtime transport. **Published:** 2026-10-19 · **Topic:** Architecture · **Reading time:** 9 min read **Source:** https://buildingmvp.com/articles/waituntil-is-not-a-queue **Author:** MVP Strategic Consulting (buildingmvp.com) --- **The three things people reach for to move work out of a web request on this stack are each missing a guarantee they are assumed to have.** `waitUntil` is cancelled when your function times out. `pg_net` has no retry at all. Cron can skip a run and can run twice. None of that is hidden. It is all in the documentation, stated once, in the place you look only after something has gone wrong. ## waitUntil is not a queue The pattern is everywhere: return a response immediately, then finish the slow work in `waitUntil`, or in Next.js `after()`, which is built on it. The shape is right. The belief that it buys you a longer or safer window is not. > Promises passed to waitUntil() will have the same timeout as the function itself. If the function times out, the promises will be cancelled. > > — Vercel documentation, Functions API reference One budget, shared. No retry. No durability. If the function is killed at its limit, work in flight is simply gone, and nothing records that it was supposed to happen. Supabase's equivalent, `EdgeRuntime.waitUntil`, has the same property: it keeps the instance alive but the maximum duration is still capped by the wall clock, CPU and memory limits. It buys no extra budget either. Use both for things you can afford to lose. Analytics, logging, cache warming. For anything you cannot lose, the work has to be written down somewhere before you return. ## pg_net is not a queue either On Supabase, the common homegrown pattern is a trigger or a scheduled job calling `pg_net` to fire an HTTP request at an Edge Function. Database Webhooks are the same thing with a nicer interface; the documentation describes them as a convenience wrapper around triggers using `pg_net`. Read the extension's own page and the guarantees are not what people assume: - It is **in beta**, with the docs noting function signatures may change. - The default timeout is **2000 milliseconds**, which is shorter than many Edge Functions legitimately take. - Both the request queue and response tables are `UNLOGGED`, which means they are not preserved through a crash or unclean shutdown. - Responses are kept for **six hours** by default. - It is intended to handle at most 200 requests per second, with the docs warning that exceeding that introduces instability. And the part that settles it: the page contains **no mention of retries or delivery guarantees at all**. There is no retry mechanism. A failed request is dropped, and the only record of the failure lives in a crash-non-durable table that expires within the day. So it is a fire-and-forget HTTP client that happens to live in your database. That is a useful thing. It is not a job queue, and building billing or email delivery on it means losing work silently. Supabase's own docs point at their queue product instead. > **Note.** If you do use it, the documented way to find out what you lost is to query `net._http_response` for rows where `status_code >= 400` or `error_msg` is not null. Do that on a schedule, within the six hour window, or the evidence ages out. ## Neither platform gives you a dead letter queue A dead letter queue is where a message goes after failing too many times, so one poisoned item stops blocking and starts being visible. It is item 20 on that list of 111, and on this stack you have to build it. **Vercel Queues** says so directly: there is no built-in dead letter queue, and you handle poisoned messages at the application level. The default that makes this urgent is `maxDeliveries`, which defaults to **unlimited**. Combine that with how delivery is billed and you have a slow leak that never stops: > Every delivery to a push consumer is a function invocation. If a delivery fails by timing out, it is billed for the function's full maxDuration at its configured memory. > > — Vercel documentation, Queues concepts A message that always times out therefore bills your maximum duration, at your configured memory, forever. Set `maxDeliveries`. There is also a genuinely surprising deployment trap documented on the same page: promoting or rolling back to a different deployment does not stop deliveries to the old one. A deployment that was live for a few minutes can keep processing messages for as long as the retention period, 24 hours by default. The documented remedy is to delete the deployment, not to roll back past it. **Supabase Queues**, built on pgmq, has no dead letter concept either. Its delivery claim needs reading carefully: exactly once delivery *within a customisable visibility window*. Across windows, that is at-least-once, which is the normal and correct guarantee, but it is not what the phrase sounds like. The hook for building your own is `read_ct`, which increments every time a message is read. Cap it, and move anything past the cap to an archive or a separate queue. Notably, Supabase's own flagship example implementation does not cap it, so it will retry a poison message indefinitely. One framing worth borrowing, from a talk on the subject: > This is a safety net and it's not a retry mechanism. Meaning if a message ends up in a dead letter queue, it's actually a very bad practice to put them back into the queue. > > — Software Developer Diaries, Deep dive into Dead-Letter Queues And the cost nobody budgets for, from the same talk: a dead letter queue only works if somebody looks at it. ## Picking a realtime transport Start with a correction, because the most repeated fact here is now wrong. **Vercel supports WebSockets.** It went to public beta in June 2026 and is available on all plans, requiring Fluid compute. For Next.js specifically there is still no native upgrade API, and the documented approach is described as a workaround, so expect the API to move. The constraint that does survive, and that governs the decision, is that both WebSocket and SSE connections die when the function hits its maximum duration. On Hobby that is a **five minute hard ceiling on any connection**. Reconnect handling is not polish, it is the feature. Which is what decides it: - **Polling every 30 to 60 seconds.** Unglamorous and correct more often than people admit. No long-lived connection, so the duration ceiling never applies. - **Server-Sent Events,**for anything one-directional: streaming model output, job progress, notifications. The browser reconnects automatically, which directly answers the duration ceiling. It is text only, and MDN's well-known six connection limit applies only when not using HTTP/2. - **WebSockets,** when the client genuinely sends messages mid-stream: collaboration, multiplayer, interactive sessions. You write the reconnect logic yourself, and state must live outside the function, because a new connection is not guaranteed to reach the same instance. ## If you are on Supabase, use Broadcast Supabase Realtime has two mechanisms that look interchangeable and are not. Postgres Changes listens to the database. Broadcast sends messages. The documentation is unusually direct about why that matters: > Postgres Changes authorizes every event against each subscriber, so throughput scales with the number of subscribers, not the write rate. Changes are also processed on a single thread, which means larger compute add-ons don't meaningfully increase Postgres Changes throughput. > > — Supabase documentation, Postgres Changes Throughput scaling with your audience rather than your workload is the opposite of what you want, and paying for a bigger database does not fix it. Their published benchmark has a small instance with row level security on and 3,000 clients handling five database changes per second. Billing follows the same shape: one database change seen by five subscribers counts as five messages. The free tier allows 200 concurrent connections and two million messages a month, which a busy table with a couple of hundred listeners will consume faster than you expect. Supabase's own threshold for switching is around 3,000 concurrent subscribers, but the architectural reason to prefer Broadcast applies well below that. > **Note.** A related trap for anyone reaching for Postgres primitives. `LISTEN` and `NOTIFY`are a real pub/sub mechanism, but Supabase's recommended connection mode for serverless is transaction mode through the pooler, and the docs list `listen` and `notify` among the session state that is lost between transactions. Session-level advisory locks are on that list too, which is why advisory locks in this environment must be the transaction-scoped variety. ## One thing nobody can answer Free Supabase projects pause after a period of low activity. The documentation describes the threshold as seven days, and every time it defines activity it qualifies it the same way: *user* database activity, *user* queries, a few *user* requests. The popular workaround is a scheduled job that pings your own database to keep it awake. Whether that counts is **addressed nowhere in the documentation**. The repeated word “user” points against it. It is not stated either way. Which makes it a bad thing to depend on. If your project genuinely needs to stay up, the answer is a paid plan, not a trick that rests on an undocumented interpretation. Worth knowing the restore window is now a year rather than the ninety days most community posts still quote. ## The shape that works - **Write it down before you acknowledge it.** A row in a table is durable; `waitUntil` is not. - **Cap retries explicitly,** because the default on Vercel Queues is unlimited and every failed delivery bills a full function duration. - **Build the dead letter queue yourself.** Neither platform has one. Then actually read it. - **Treat pg_net as fire and forget,** because that is what it is. Poll the response table for failures within six hours or lose them. - **Make every job safe to run twice and safe to skip.** Cron on this platform does both. - **Prefer polling, then SSE.** Reach for WebSockets when the client genuinely needs to talk back. - **Use Broadcast rather than Postgres Changes** unless you have a specific reason not to. --- *Originally published at https://buildingmvp.com/articles/waituntil-is-not-a-queue. Free to quote with attribution.*