Skip to content

Commit c60c93c

Browse files
chrismilleruktrivikr
authored andcommitted
doc, http2: add sections for server.close()
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>
1 parent 4545cc1 commit c60c93c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

doc/api/http2.md

+27
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,18 @@ added: v8.4.0
15381538
The `'timeout'` event is emitted when there is no activity on the Server for
15391539
a given number of milliseconds set using `http2server.setTimeout()`.
15401540

1541+
#### server.close([callback])
1542+
<!-- YAML
1543+
added: v8.4.0
1544+
-->
1545+
- `callback` {Function}
1546+
1547+
Stops the server from accepting new connections. See [`net.Server.close()`][].
1548+
1549+
Note that this is not analogous to restricting new requests since HTTP/2
1550+
connections are persistent. To achieve a similar graceful shutdown behavior,
1551+
consider also using [`http2session.close()`] on active sessions.
1552+
15411553
### Class: Http2SecureServer
15421554
<!-- YAML
15431555
added: v8.4.0
@@ -1645,6 +1657,18 @@ negotiate an allowed protocol (i.e. HTTP/2 or HTTP/1.1). The event handler
16451657
receives the socket for handling. If no listener is registered for this event,
16461658
the connection is terminated. See the [Compatibility API][].
16471659

1660+
#### server.close([callback])
1661+
<!-- YAML
1662+
added: v8.4.0
1663+
-->
1664+
- `callback` {Function}
1665+
1666+
Stops the server from accepting new connections. See [`tls.Server.close()`][].
1667+
1668+
Note that this is not analogous to restricting new requests since HTTP/2
1669+
connections are persistent. To achieve a similar graceful shutdown behavior,
1670+
consider also using [`http2session.close()`] on active sessions.
1671+
16481672
### http2.createServer(options[, onRequestHandler])
16491673
<!-- YAML
16501674
added: v8.4.0
@@ -3121,7 +3145,9 @@ following additional properties:
31213145
[`http2.createSecureServer()`]: #http2_http2_createsecureserver_options_onrequesthandler
31223146
[`http2.Server`]: #http2_class_http2server
31233147
[`http2.createServer()`]: #http2_http2_createserver_options_onrequesthandler
3148+
[`http2session.close()`]: #http2_http2session_close_callback
31243149
[`http2stream.pushStream()`]: #http2_http2stream_pushstream_headers_options_callback
3150+
[`net.Server.close()`]: net.html#net_server_close_callback
31253151
[`net.Socket`]: net.html#net_class_net_socket
31263152
[`net.Socket.prototype.ref`]: net.html#net_socket_ref
31273153
[`net.Socket.prototype.unref`]: net.html#net_socket_unref
@@ -3134,6 +3160,7 @@ following additional properties:
31343160
[`response.write(data, encoding)`]: http.html#http_response_write_chunk_encoding_callback
31353161
[`response.writeContinue()`]: #http2_response_writecontinue
31363162
[`response.writeHead()`]: #http2_response_writehead_statuscode_statusmessage_headers
3163+
[`tls.Server.close()`]: tls.html#tls_server_close_callback
31373164
[`tls.TLSSocket`]: tls.html#tls_class_tls_tlssocket
31383165
[`tls.connect()`]: tls.html#tls_tls_connect_options_callback
31393166
[`tls.createServer()`]: tls.html#tls_tls_createserver_options_secureconnectionlistener

0 commit comments

Comments
 (0)