You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: clarify close hook availability across preset types
Note that the close hook only fires on long-running server presets
(node, bun, deno) and not in serverless/edge environments. Guide plugin
authors toward the response hook or waitUntil for per-request cleanup
that works across all presets.
Co-authored-by: Cursor <cursoragent@cursor.com>
-`"request", (event) => {}` - Called when a request is received.
58
-
-`"error", (error, { event? }) => {}` - Called when an error is captured.
59
-
-`"response", (response, event) => {}` - Called when a response is sent.
60
-
-`"close", () => {}` - Called when the server receives a shutdown signal (`SIGTERM` or `SIGINT`).
57
+
-`"request", (event) => {}` - Called when a request is received. Available in all presets.
58
+
-`"error", (error, { event? }) => {}` - Called when an error is captured. Available in all presets.
59
+
-`"response", (response, event) => {}` - Called when a response is sent. Available in all presets.
60
+
-`"close", () => {}` - Called when the server receives a shutdown signal (`SIGTERM` or `SIGINT`). Only available in long-running server presets (Node.js, Bun, Deno). Not called in serverless or edge environments.
When the server receives a shutdown signal (`SIGTERM` or `SIGINT`), the `close` hook is called, allowing plugins to run async cleanup before the process exits. This is useful for flushing telemetry, draining database connections, stopping job queues, and other teardown tasks.
80
+
On long-running server presets (`node-server`, `node-cluster`, `bun`, `deno-server`), the `close` hook fires when the process receives `SIGTERM` or `SIGINT`, allowing plugins to run async cleanup before exit.
Serverless and edge runtimes (Cloudflare Workers, AWS Lambda, Vercel, Netlify, Deno Deploy) do not have a shutdown signal–the platform terminates the execution context without notice. The `close` hook will not fire in these environments.
94
+
95
+
For per-request cleanup that works across all presets, use the `"response"` hook or `request.waitUntil()` instead:
0 commit comments