Node.js Vercel Functions now support per-path request cancellation
Vercel Functions on Node.js now support per-path request cancellation, letting developers stop execution early when users navigate away, close a tab, or cancel an AI chat stream.
can now detect when a request is cancelled and stop execution before completion. This is configurable on a per-path basis, and includes actions like navigating away, closing a tab, or hitting stop on an AI chat to terminate compute processing early.Vercel Functions using Node.js This reduces unnecessary compute, token generation, and sending data the user would never see.
To enable cancellation, add to your configuration. You can apply it to specific paths or all functions:"supportsCancellation": truevercel.json Once enabled, you can listen for cancellation using or the event:Request.signal.abortedabort If you’re using the , forward the to your stream:AI SDKabortSignal Learn more about .cancelling Function requests Read more