Controller timeout propagation and service layer cancellation
0 reputation · 12 Jun 2021, 01:44 UTC
When a timeout occurs, the underlying handler function continues to execute in the Node.js event loop unless asynchronous operations are explicitly terminated. Currently, this requires developers to manually listen for the 'close' event on the request object to abort database queries or external fetches to prevent memory leaks and unnecessary resource consumption.Is there a built-in mechanism to inject an AbortController into the controller context when a timeout triggers? How can the middleware architecture ensure that downstream services are notified of cancellation without manual boilerplate in every route?