Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fastify] Compression does not work in exception filter #10736

Closed
3 of 15 tasks
sgrigorev opened this issue Dec 17, 2022 · 1 comment
Closed
3 of 15 tasks

[Fastify] Compression does not work in exception filter #10736

sgrigorev opened this issue Dec 17, 2022 · 1 comment
Labels
needs triage This issue has not been looked into

Comments

@sgrigorev
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Client receives nothing if a response is quite big and if it is sent from exception filter. Also there is error in logs

"err":{"type":"Error","message":"premature close","stack":"Error: premature close\n    at onclosenexttick (/Users/sgrigorev/Projects/nestjs-compress-issue/node_modules/end-of-stream/index.js:54:86)\n    at processTicksAndRejections (internal/process/task_queues.js:77:11)"},"msg":"premature close"}

Minimum reproduction code

https://github.com/sgrigorev/nestjs-compress-issue

Steps to reproduce

See readme in reproduction code

Expected behavior

Client must not receive empty response if compression is enabled

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

9.2.1

Packages versions

    "@fastify/compress": "^6.2.0",
    "@nestjs/common": "^9.2.1",
    "@nestjs/core": "^9.2.1",
    "@nestjs/platform-fastify": "^9.2.1",
    "fastify": "^4.10.2",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^7.2.0"

Node.js version

16.14.2

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

  1. Compression works if you run fastify without nestjs
  2. It works if you decrease response payload.
  3. It works if response is sent from controller

There was a similar issue with "Premature close" error in the @fastify/compress library. It might be related.

@sgrigorev sgrigorev added the needs triage This issue has not been looked into label Dec 17, 2022
@kamilmysliwiec
Copy link
Member

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.

@nestjs nestjs locked and limited conversation to collaborators Dec 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants