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

Serialization errors will be send to errorHandler #3674

Merged
merged 1 commit into from Feb 1, 2022

Conversation

int1ch
Copy link
Contributor

@int1ch int1ch commented Feb 1, 2022

I have found that fastify sometimes can throw errors not caught by errorHandler and it's difficult to understand where it comes from.

Reduced Example you can find in the committed test:
Response schema with required field throws an error from fast-json-stringify when a required field is not found.

fastify.get('/', {
    schema: {
      response: {
        200: {
          type: 'object',
          properties: {
            name: { type: 'string' }
          },
          required: ['name']
        }
      }
    }

  }, function (req, reply) {
    reply.code(200).send({ no: 'thing' })
  })

So I decided that it will be ok idea to send the captured error to errorHandler like validation error, and add a sign that the error comes from serialization.

But here I need your advice on how to envelop error propely.

Checklist

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina
Copy link
Member

mcollina commented Feb 1, 2022

Note that this has been refactored and improved in next, however this seems a very good fix.

@RafaelGSS RafaelGSS added the benchmark Label to run benchmark against PR and main branch label Feb 1, 2022
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the benchmark Label to run benchmark against PR and main branch label Feb 1, 2022
@RafaelGSS RafaelGSS added the benchmark Label to run benchmark against PR and main branch label Feb 1, 2022
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the benchmark Label to run benchmark against PR and main branch label Feb 1, 2022
Copy link
Member

@RafaelGSS RafaelGSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@mcollina mcollina merged commit 7cdc903 into fastify:main Feb 1, 2022
@github-actions
Copy link

github-actions bot commented Feb 2, 2023

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants