Feature Request: Support `waitUntil` in middleware for background task scheduling
Author: fbwe425Created Sep 6, 2026Updated Sep 8, 2026
Summary
When building serverless applications with Hono on Cloudflare Workers or similar edge runtimes, it's common to need waitUntil() from the execution context to fire-and-forget background tasks (e.g. logging, analytics, cache warming) without blocking the response.
Problem
Currently, accessing ctx.executionCtx.waitUntil() inside Hono middleware requires either:
- Passing the execution context manually through every handler
- Using a workaround via
c.envto store it
There's no idiomatic, first-class way to use waitUntil in middleware.
Proposed Solution
Expose a c.waitUntil(promise) helper on the Hono Context object, similar to how c.executionCtx already works but with a more ergonomic interface:
app.use(async (c, next) => {
await next()
// Fire-and-forget: log request after response is sent
c.waitUntil(logRequest(c.req.raw))
})Why This Matters
- Cloudflare Workers, Deno Deploy, and Vercel Edge all support
waitUntilsemantics - Frameworks like Remix and Next.js are adding similar patterns
- Makes it easier to add observability (logging, tracing) without impacting response latency
Additional Context
- Related: https://developers.cloudflare.com/workers/runtime-apis/context/#waituntil
- Hono already has
c.executionCtx— this would be a thin ergonomic wrapper
Would love to hear if there's a reason this hasn't been added, or if there's a recommended pattern I'm missing!
Source: honojs/hono