Nitro · handler

NITRO0033Pass background work to event.waitUntil

Report $fetch(), fetch(), event.fetch() and storage calls that a Nitro handler starts as a bare statement, without awaiting, returning or passing them to event.waitUntil(), on deployment presets where Nitro forwards waitUntil to the platform.

Why it happens

Cloudflare Workers and Vercel Functions can stop running once the response is sent, so a request or storage write the handler did not wait for can be cut off without an error. Nitro forwards event.waitUntil() to the platform's waitUntil on the Cloudflare presets (Nitro 2 and 3) and on Vercel (Nitro 3 only). Doctor reports only when the config names one of those presets statically and stays quiet for other or unknown presets. This is not a generic no-floating-promises check: a floating promise is fine in a long-lived Node.js server, and the fix here is event.waitUntil(), which only exists because of the platform. Doctor only counts calls it knows return a promise, and only statements in the handler body itself.

Fix

Pass the promise to event.waitUntil() so the platform keeps the request alive until it settles, or await it when the response depends on it.

Example

Keep the webhook alive with event.waitUntil()

Before

export default defineEventHandler(async (event) => {
  const order = await readBody(event)
  $fetch('https://hooks.example.com/order', { method: 'POST', body: order })
  return { ok: true }
})

After

export default defineEventHandler(async (event) => {
  const order = await readBody(event)
  event.waitUntil($fetch('https://hooks.example.com/order', { method: 'POST', body: order }))
  return { ok: true }
})

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --framework nitro --rules nitro/handler/require-waituntil-for-background-work
Copyright © 2026