Skip to main content
The bunny.net EdgeScript Runtime is based on Deno, so you can use a subset of what is available from Deno or Node. On top of that, we provide functions that change how the script behaves in our environment or bind it to other bunny.net services.

waitUntil

The waitUntil function extends the life of the isolate running a request. Use it when a script needs to keep working after the request it answered has finished. Even when no other requests are routed to the script, the invocation stays alive. It is useful for holding WebSocket connections open, refreshing a cache entry in the background, or firing off telemetry once the response has gone back to the client.

Signature

Parameters

Promise<unknown>
required
A promise representing background work. The isolate will stay alive until this promise settles (resolves or rejects).

Returns

void. waitUntil does not return a value.
You can call waitUntil multiple times; the script will only be evicted once every given promise has been resolved.

Example

Return the response to the client immediately while a slower task, in this case populating the cache, finishes in the background.

References

Last modified on August 17, 2026