-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
fix: prevent premature close error #149
Conversation
88dbb0e
to
cfad3b5
Compare
test/static.test.js
Outdated
fastify.errorHandler = (_, __, reply) => { | ||
reply.send('default-error-obj') | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also add a test where fastify.errorHandler
is undefined
.
bd4caaf
to
d296b94
Compare
Implemented feedbacks on this PR, but build is still not green until fastify/light-my-request#102 is merged and version is bumped. |
d296b94
to
cc76dd0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Thank you, @salmanm! |
As reported in fastify/fastify#2616 & #116, the module fails and logs an error when client closes the request prematurely. This PR fixes that by adding a custom
errorHandler
in the route config so that the specificERR_STREAM_PREMATURE_CLOSE
can be handled in a special way. For all other errors, we still fallback to the defaultfastify.errorHandler
which was introduced in 3.7.0.Checklist
npm run test
andnpm run benchmark
and the Code of conduct