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

Fix simplify reply sent monitoring #3079

Merged

Conversation

sergejostir
Copy link
Contributor

@sergejostir sergejostir commented May 17, 2021

Checklist

After another review, I noticed a problem with my previous PR #3072.

I figured out that when http2 is used and the request method is "HEAD", response.finished will be always true (my understanding after reading https://nodejs.org/api/http2.html#http2_response_finished was that it behaves the same way as response.writableEnded, since that is suggested as a replacement). This is problematic with Node.js versions prior to 12.9.0 where response.writableEnded does not exist.

#2233 was made to cope with this problem, but it relied on response.writable, which by my testing will stay true even after the response has ended, so we cannot use it as an indicator.

Therefore, I added additional check, so now both response.finished as well as response.headersSent has to be true in order for reply to be considered sent. This change only applies for Node.js versions prior to 12.9.0 because newer versions will be using response.writableEnded which works correctly.

I also removed additional checks from preValidationCallback and preHandlerCallback that I missed, which were introduced by #2233. They are not needed any more with the new way that the reply.sent works.

PS: The test/http2/head.test.js was supposed to fail before on node10, but I only noticed that in my local environment today. Therefore I didn't include any new tests, since the part that this PR targets is already covered by an existing test.

I'm sorry for any inconvenience caused.

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

Why weren't any tests failing in CI before this change?

@Eomm
Copy link
Member

Eomm commented May 17, 2021

PS: The test/http2/head.test.js was supposed to fail before on node10, but I only noticed that in my local environment today. Therefore I didn't include any new tests, since the part that this PR targets is already covered by an existing test.

There is this PR that is failing #2862 on that test file. I was trying it locally but it passes so I was really confused about that tho

I don't know why my pipeline was failing and the other one no 😞

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

@Eomm I don't understand, do you approve this change?

@sergejostir
Copy link
Contributor Author

Why weren't any tests failing in CI before this change?

They were, but due to unrelated reason https://github.com/fastify/fastify/actions/runs/846451395. CI should be manually re-run I guess.

@Eomm
Copy link
Member

Eomm commented May 17, 2021

@Eomm I don't understand, do you approve this change?

No, I didn't get the chance to check this PR deeply, I was pointing out that this PR should fix the other one pipeline 🤞🏽

@jsumners
Copy link
Member

Why weren't any tests failing in CI before this change?

They were, but due to unrelated reason fastify/fastify/actions/runs/846451395. CI should be manually re-run I guess.

GitHub Actions was having some issues at the time the initial PR was being considered. Unfortunately, we merged without waiting for those to be resolved and re-running the jobs to make sure everything was green. I just re-ran them, and sure enough, the HTTP2 tests fail -- https://github.com/fastify/fastify/pull/3072/checks?check_run_id=2600626970#step:6:9795

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@mcollina mcollina merged commit 9bf6a33 into fastify:main May 17, 2021
mcollina added a commit that referenced this pull request May 26, 2021
mcollina added a commit that referenced this pull request May 29, 2021
mcollina added a commit that referenced this pull request May 29, 2021
* Revert "fix #3099 (#3100)"

This reverts commit a848b0f.

* Revert "fixup! Simplify reply sent monitoring (#3072) (#3079)"

This reverts commit 9bf6a33.

* Revert "Simplify reply sent monitoring (#3072)"

This reverts commit 212fdb7.
@github-actions
Copy link

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 May 18, 2022
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

4 participants