Skip to content

[BUG] NestJS with Fastify : response headers are empty #860

Description

@remija

[X] I've read the docs of nestjs-pino

[X] I've read the docs of pino

[X] I couldn't find the same open issue of nestjs-pino

What is the current behavior?

HTTP log messages return an empty Response Headers object when using the library as part of a NestJS application with the Fastify platform, unlike the default Express platform.

Example:

  • NestJS with Fastify
    {"level":30,"time":1647270615012,"pid":46872,"hostname":"MacBook-Pro.local","req":{"id":"req-2","method":"POST","url":"/v0/test-post","query":{},"headers":{"content-type":"application/json","user-agent":"PostmanRuntime/7.28.4","accept":"/","postman-token":"cc8db335-488b-4741-966a-87b09cb96951","host":"localhost:3000","accept-encoding":"gzip, deflate, br","connection":"keep-alive","content-length":"69"},"remoteAddress":"127.0.0.1","remotePort":51821},"res":{"statusCode":201,"headers":{}},"responseTime":7,"msg":"request completed"}

  • NestJS with Express
    {"level":30,"time":1647270754658,"pid":46900,"hostname":"MacBook-Pro.local","req":{"id":1,"method":"POST","url":"/v0/test-post","query":{},"params":{"0":"v0/test-post/remi"},"headers":{"content-type":"application/json","user-agent":"PostmanRuntime/7.28.4","accept":"/","postman-token":"7803653a-bbd3-4e7b-8733-37d59bfc0276","host":"localhost:3000","accept-encoding":"gzip, deflate, br","connection":"keep-alive","content-length":"69"},"remoteAddress":"127.0.0.1","remotePort":51829},"res":{"statusCode":201,"headers":{"x-powered-by":"Express","content-type":"application/json; charset=utf-8","content-length":"30","etag":"W/"1e-ZljF/Nt5uArBAuXc8XriunP0mGg""}},"responseTime":5,"msg":"request completed"}

What is the expected behavior?

The Response Headers must be filled in NestJS with Fastify case.

Please provide minimal example repo. Without it this issue will be closed

Please mention other relevant information such as Node.js version and Operating System.

NodeJS 14.18.1
NestJS 8.4.1 (latest, same result with other 8 versions)
nest-pino 2.5.0

Otherwise very good work, thank you ;)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions