NestJS · Middle · Question 8 of 75
How can an interceptor add a timeout to slow handlers?
- 1Set
@Timeout()on the DTO - ✓Correct answer:
next.handle().pipe(timeout(5000), catchError(...))and map the timeout toRequestTimeoutException - 3Interceptors can't affect timing
Explanation
This stops waiting for the result, but the underlying work keeps running unless you also cancel it (for example with an AbortSignal).