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
Simplify reply sent monitoring #3072
Simplify reply sent monitoring #3072
Conversation
Tests fail due to decreased coverage -- https://github.com/fastify/fastify/pull/3072/checks?check_run_id=2585550350#step:6:11141 |
48a22c9
to
8e61a47
Compare
Do you have any suggestion for solving this? I believe it's because of https://github.com/sergiz/fastify/blob/8e61a472e6d091fab328e425d23ecbb663ed6b2e/lib/reply.js#L85 |
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.
Can you do a benchmark compare?
Have you run the HTML coverage report to see what is not being covered? |
8e61a47
to
3ae6fe5
Compare
I installed the node v10 and the console already showed me that that line was problematic. I included two more tests now which cover both possibilities.
How should I do that? I ran |
Yes, |
|
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
I'm a bit nervous about this change as it might have some unplanned behavior change and break people code. I guess we can revert in that case.
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.
Can you rebase to |
3ae6fe5
to
5e5a9f2
Compare
Done. |
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
Unfortunately this is a breaking change, I'll revert on main and reapply it on |
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. |
Checklist
npm run test
andnpm run benchmark
and the Code of conduct
This PR simplifies "reply.sent" monitoring; instead of manually setting the kReplySent property all over the package (in more than 10 different places!), it relies on node's response.writableEnded (since fastify supports node versions prior to 12.9.0 which added "writableEnded", reponse.finished is used as a fallback).
When the user sets "reply.sent = true" or uses reply.hijack(), the kReplySentOverwritten property is now used.
You can see that all existing tests (except for one which I had to negligibly modify because it didn't use the proper object) are passing, therefore I believe no changes for the end users were introduced.