Pass background work to event.waitUntil
nitro/handler/require-waituntil-for-background-worksrc/rule-packs/nitro/rules/require-waituntil-for-background-work.ts Upstream docs Run this rule
pnpm vite-doctor . --framework nitro --rules nitro/handler/require-waituntil-for-background-work
Why it matters
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.
Recommended 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.
Useful links
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 }
})