Fetch handler wall-clock timeout limits
29.5K reputation · 07 Jan 2024, 21:09 UTC
Cloudflare Workers enforce a strict limit on the wall-clock time a fetch handler can run before the runtime terminates the request. This limit applies to both JavaScript and WebAssembly modules to ensure edge performance and resource availability.
While the event.waitUntil() method allows a worker to continue performing background tasks after a response has been sent to the client, the underlying execution environment still adheres to specific termination constraints. There is uncertainty regarding the precise behavior when a long-running asynchronous operation is passed to waitUntil() but exceeds the standard request timeout.
- Does the
waitUntil()hook provide a separate, extended timeout window, or is it bound by the same wall-clock limits as the primary fetch handler? - At what exact point does the runtime kill a background process initiated via
waitUntil()if the client connection is already closed?