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
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.
Runtime maintenance and compatibility
Edge Scripting runs on our own customized Deno runtime. With Deno winding down
active development, we want to reassure you that nothing changes for Edge
Scripting.
Your existing scripts will continue running, and you can keep developing and
deploying new ones as usual. We’ll continue maintaining our runtime with V8
upgrades, security fixes, and support for new TypeScript and Node.js features.
We’re monitoring developments and evaluating our long-term options. Whatever
runtime we use in the future, we’re committed to preserving compatibility with
existing scripts and APIs. We’ll share more about our long-term plans well
before Deno’s support window ends.
References