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

Context can be undefined in the error handler #677

Closed
mcollina opened this issue Dec 1, 2021 · 0 comments · Fixed by #678
Closed

Context can be undefined in the error handler #677

mcollina opened this issue Dec 1, 2021 · 0 comments · Fixed by #678
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mcollina
Copy link
Collaborator

mcollina commented Dec 1, 2021

In production it's possible to see:

TypeError: Cannot read properties of undefined (reading 'reply')
    at defaultErrorFormatter (/app/node_modules/mercurius/lib/errors.js:67:19)
    at Object.<anonymous> (/app/node_modules/mercurius/lib/routes.js:139:40)
    at handleError (/app/node_modules/fastify/lib/reply.js:555:20)
    at onErrorHook (/app/node_modules/fastify/lib/reply.js:524:5)
    at _Reply.Reply.send (/app/node_modules/fastify/lib/reply.js:128:5)
    at done (/app/node_modules/fastify/lib/contentTypeParser.js:167:13)
    at Parser.defaultJsonParser [as fn] (/app/node_modules/fastify/lib/contentTypeParser.js:262:14)
    at IncomingMessage.onEnd (/app/node_modules/fastify/lib/contentTypeParser.js:243:27)
    at AsyncResource.runInAsyncScope (node:async_hooks:199:9)
    at IncomingMessage.emit (node:events:402:35)

This can happen if an error is thrown in a hook. We should be adding back the check for Context in the error handler.

Originally posted by @SimenB in #653 (comment)

@mcollina mcollina added bug Something isn't working good first issue Good for newcomers labels Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant