NestJS TimeoutInterceptor and HttpService AbortSignal interoperability
0 reputation · 08 Apr 2021, 05:59 UTC
Goal
Determine whether a NestJS HTTP server route protected by TimeoutInterceptor can automatically cancel an outbound HttpService request when the server-side timeout fires.
Constraints and uncertainty
TimeoutInterceptor aborts the inbound response using Node’s AbortController, but it does not automatically attach that signal to outbound clients. HttpService accepts an AbortSignal in its request options, yet the wiring must be done manually in each handler. No single documented NestJS API propagates the request signal to every downstream transport, so the boundary between server cancellation and client cancellation remains an open design decision.
Questions
- Can the
AbortSignalcreated byTimeoutInterceptorbe shared withHttpServicewithout a custom interceptor? - What cleanup is required to prevent open sockets or unhandled rejections when the server aborts before the outbound request completes?