Amit Alkobi
Amit Alkobi

Reputation: 1

NestJS interceptor doesn't work with StreamableFile

When using timeout interceptor (TimeoutInterceptor in timeout.interceptor.ts) with EP that returns StreamableFile, the interceptor doesn't work - it doesn't early return a response when timeout passed.

It does work when returning a list of string.

Issue in nestjs/nest

How to reproduce

Repro repo

  1. Start the app in dev mode
  2. Visit http://localhost:3000/foo/file The foo/file endpoint takes 3 seconds to resolve while the timeout interceptor sets a timeout of 10 ms

Current behavior

File is downloaded.

Expected behavior

A response with code 408 should be returned.

Note that the timeout interceptor works when submitting a request to GET /foo

Set an interceptor that returns a timeout response if certain amount of time passed before the request was resolved. It doesn't work for endpoints that return StreamableFile

Upvotes: 0

Views: 50

Answers (0)

Related Questions