Skip to content

Worse performance with response schema when 'const' keyword is used #502

@DanieleFedeli

Description

@DanieleFedeli

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.3.0

Plugin version

No response

Node.js version

16.13.0

Operating system

macOS

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

13.0

Description

When specifying the response schema with 'const' I noticed that the RPS decreased.

Steps to Reproduce

Options used:

{
  schema: {
    response: {
        200: {
          type: "object",
          properties: {
            msg: { type: "string" },
          }
      }
   }
}

Schema benchmark:
Screenshot 2022-08-07 alle 12 06 23

Options used:

{
  schema: {
    response: {
        200: {
          type: "object",
          properties: {
            msg: { const: "hello world" },
          }
      }
   }
}

Schema with const:
Screenshot 2022-08-07 alle 12 08 13

Repository with the code: https://github.com/DanieleFedeli/fastify-response-schema-issue

Expected Behavior

I expect at least the same performance when specifying const in the schema.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bughelp wantedHelp the community by contributing to this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions