Skip to content

Empty reply.request in loggers.serializers.res #5556

@mch-dsk

Description

@mch-dsk

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.6.0

Plugin version

No response

Node.js version

20.11.1

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

14.5

Description

Hello, I want to log the duration of a request using a custom serializers. While doing so, I encoutered the following error :

const fastify = Fastify({
    logger: {
        serializers: {
            res(reply) {
                console.log(reply.request); // undefined
            },
        },
    },
});

When an user aborts a request, reply.request is empty.

This line should be logStreamError(reply.log, err, reply).

Link to code that reproduces the bug

No response

Expected Behavior

reply.request should be correctly populated

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions