-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Http2SecureServer.close fails #19711
Comments
Maybe it is not a bug: "Stops the server from accepting new connections and keeps existing connections." (from https://nodejs.org/api/net.html#net_server_close_callback) |
Http2Server.close() has not the same behaviour as HttpServer.close() and HttpsServer.close(). |
I think they have the same behavior, consider: import http from 'http'
let sv=http.createServer((rq,rs)=>{})
sv.listen(8000)
let rq=http.get('http://localhost:8000/',rs=>{
sv.close()
}) |
That said, it doesn't harm to clarify that in the docs. |
I would guess @aabfred is new to HTTP/2. Would you like to figure the differences out, and describe the illusion that they don't have the same behavior? I think it might help making a good documentation. |
Hi, I'm interested in making some improvements here if this is available? I noticed that inherited methods such as I also thought it might be worth introducing a brief explainer near the top to cover the most obvious differences (i.e. introduction of sessions and streams). Would be keen to hear thoughts on this. |
OK, PR sent. I've kept it simple for the moment but I have enough context now that I can add more details if needed. The perceived behaviour seems to be that I think that calling http2Session.close() on all active sessions will help to gracefully close open sockets so I made a suggestion in the footnotes but I may be wrong (looking to validate this). 💭 if calling session.close() on all children is a common use case, perhaps this should be default behaviour? I saw a mention of an |
Clarify current behavior of http2server.close() and http2secureServer.close() w.r.t. perceived differences when compared with httpServer.close(). Fixes: nodejs#19711
Clarify current behavior of http2server.close() and http2secureServer.close() w.r.t. perceived differences when compared with httpServer.close(). Fixes: #19711 PR-URL: #19802 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Clarify current behavior of http2server.close() and http2secureServer.close() w.r.t. perceived differences when compared with httpServer.close(). Fixes: nodejs#19711 PR-URL: nodejs#19802 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Clarify current behavior of http2server.close() and http2secureServer.close() w.r.t. perceived differences when compared with httpServer.close(). Fixes: #19711 Backport-PR-URL: #20456 PR-URL: #19802 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Clarify current behavior of http2server.close() and http2secureServer.close() w.r.t. perceived differences when compared with httpServer.close(). Fixes: #19711 Backport-PR-URL: #20456 PR-URL: #19802 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Clarify current behavior of http2server.close() and http2secureServer.close() w.r.t. perceived differences when compared with httpServer.close(). Fixes: #19711 Backport-PR-URL: #20456 PR-URL: #19802 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Problem:
Closing an Http2Server runs only when it has no connection;
Otherwise, no "close" or "error" event is emitted after close(), and script doesn't exit (server still listening)
bug.js:
const
http2 = require( "http2" ),
srv = http2.createServer();
srv.listen(9000);
const client = http2.connect("http://localhost:9000");
setTimeout(() => { srv.close() }, 500);
$ export NODE_DEBUG=http2; node ./bug.js
HTTP2 30406: Http2Session client: created
(node:30406) ExperimentalWarning: The http2 module is an experimental API.
HTTP2 30406: Http2Session server: received a connection
HTTP2 30406: Http2Session server: setting up session handle
HTTP2 30406: Http2Session server: sending settings
HTTP2 30406: Http2Session server: submitting settings
HTTP2 30406: Http2Session server: created
HTTP2 30406: Http2Session client: setting up session handle
HTTP2 30406: Http2Session client: sending settings
HTTP2 30406: Http2Session client: submitting settings
HTTP2 30406: Http2Session client: new settings received
HTTP2 30406: Http2Session server: new settings received
HTTP2 30406: Http2Session server: settings received
HTTP2 30406: Http2Session client: settings received
The text was updated successfully, but these errors were encountered: