-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
[x] http: added closed property #28621
Conversation
847be88
to
a554a24
Compare
d5bb19f
to
02b82d8
Compare
@nodejs/http PTAL |
0321930
to
49ab8fa
Compare
I've got a lot of other pending fixes and PR's that depend on this. Would be nice to get it merged before I start "spamming" with new PR's. |
@nodejs/collaborators This could use some reviews. |
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.
Nice, LGTM. Would be great if there were docs and a test for the added http2 compat properties.
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.
The code changes look good but I am just not sure we should do this. It adds another property and I am really not sure why we need it vs. just listening to an event. An extra variable for every single http request for something I don't understand isn't something I'm comfortable approving. Can you motivate this?
@benjamingr Because currently, there is no way to check whether an http object is closed or not. If you are using a framework such as koa or similar it might already be too late to register a In summary there are cases already out in the wild which cannot solve this and are incorrectly depending on |
Also I have other pending fixes that depend on this, e.g.
|
If you are worried about size we can also do things like: nxtedition@7355716 |
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.
I still think .closed
should be done on the framework side but the argument regarding other fixes this would enable (in particular doing work on a closed request) are a compelling enough argument to me.
f8eeaee
to
9bcc445
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.
I'm not convinced of this change. I would rather prefer that we switch IncomingMessage
to use the the emitClose
and autoDestroy
option instead, making it less of a snowflake in the stream world. I'm not sure if that is actually doable.
@mcollina would it make more sense to rename |
@mcollina I tried the |
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.
I don't see tests or docs for http2.
45eead6
to
2f5b684
Compare
@mcollina you asked me to add more checks to https://github.com/nodejs/node/blob/master/test/parallel/test-http-connect-req-res.js. Those checks will actually fail since e.g. |
Please add tests that verifies the current behavior, having it unspecified is going to cause more issues. Add a comment on it that explain your thinking. I would also open a separate issue about it. |
@mcollina: Done, if you agree, I will add a separate PR with test that are "correct" and fail. |
@@ -446,6 +450,10 @@ class Http2ServerResponse extends Stream { | |||
stream.on('timeout', onStreamTimeout(kResponse)); | |||
} | |||
|
|||
get closed() { | |||
return this[kState].closed; | |||
} |
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.
No tests have been added for these.
Closing for now. |
This is an alternative to
finished
andonFinished.isFinished
to more accurately indicate when a request/response has completed.With this PR the frequently used
on-finished
npm package should no longer be necessary as the "same" (assumed) functionality can be achieved using the'close'
event andclosed
property.Refs: #28412
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes