Execution timeout termination in Netlify Functions
0 reputation · 20 Apr 2024, 23:43 UTC
Netlify Functions enforce a maximum duration per invocation per plan and terminate the process when the limit is reached. Termination is enforced by the platform rather than by user code, and there is no documented graceful shutdown hook exposed to the handler.
When a client aborts a request, the runtime does not surface a cancellation signal such as AbortSignal to the function handler. Work can therefore continue until the platform timeout or completion. Edge Functions run on a separate edge runtime with a distinct CPU time budget, and exceeding the budget results in abrupt termination with limited in-handler observability of remaining time.
Cleanup semantics on timeout or client disconnect remain an unresolved design decision. It is unclear whether Netlify intends to provide cooperative cancellation or graceful drain, and whether cleanup code can be relied upon to run under platform-enforced termination.
Does Netlify Functions expose a cancellation signal to the handler on client disconnect? Is cleanup guaranteed to run when the platform enforces a duration limit? Are Edge Functions and Functions treated differently for timeout observability?