Skip to content

Commit 88d4794

Browse files
chrismillerukMylesBorins
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 Backport-PR-URL: #20456 PR-URL: #19802 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 82b56b6 commit 88d4794

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
@@ -1544,6 +1544,18 @@ added: v8.4.0
15441544
The `'timeout'` event is emitted when there is no activity on the Server for
15451545
a given number of milliseconds set using `http2server.setTimeout()`.
15461546

1547+
#### server.close([callback])
1548+
<!-- YAML
1549+
added: v8.4.0
1550+
-->
1551+
- `callback` {Function}
1552+
1553+
Stops the server from accepting new connections. See [`net.Server.close()`][].
1554+
1555+
Note that this is not analogous to restricting new requests since HTTP/2
1556+
connections are persistent. To achieve a similar graceful shutdown behavior,
1557+
consider also using [`http2session.close()`] on active sessions.
1558+
15471559
### Class: Http2SecureServer
15481560
<!-- YAML
15491561
added: v8.4.0
@@ -1651,6 +1663,18 @@ negotiate an allowed protocol (i.e. HTTP/2 or HTTP/1.1). The event handler
16511663
receives the socket for handling. If no listener is registered for this event,
16521664
the connection is terminated. See the [Compatibility API][].
16531665

1666+
#### server.close([callback])
1667+
<!-- YAML
1668+
added: v8.4.0
1669+
-->
1670+
- `callback` {Function}
1671+
1672+
Stops the server from accepting new connections. See [`tls.Server.close()`][].
1673+
1674+
Note that this is not analogous to restricting new requests since HTTP/2
1675+
connections are persistent. To achieve a similar graceful shutdown behavior,
1676+
consider also using [`http2session.close()`] on active sessions.
1677+
16541678
### http2.createServer(options[, onRequestHandler])
16551679
<!-- YAML
16561680
added: v8.4.0
@@ -3126,7 +3150,9 @@ following additional properties:
31263150
[`http2.createSecureServer()`]: #http2_http2_createsecureserver_options_onrequesthandler
31273151
[`http2.Server`]: #http2_class_http2server
31283152
[`http2.createServer()`]: #http2_http2_createserver_options_onrequesthandler
3153+
[`http2session.close()`]: #http2_http2session_close_callback
31293154
[`http2stream.pushStream()`]: #http2_http2stream_pushstream_headers_options_callback
3155+
[`net.Server.close()`]: net.html#net_server_close_callback
31303156
[`net.Socket`]: net.html#net_class_net_socket
31313157
[`net.Socket.prototype.ref`]: net.html#net_socket_ref
31323158
[`net.Socket.prototype.unref`]: net.html#net_socket_unref
@@ -3139,6 +3165,7 @@ following additional properties:
31393165
[`response.write(data, encoding)`]: http.html#http_response_write_chunk_encoding_callback
31403166
[`response.writeContinue()`]: #http2_response_writecontinue
31413167
[`response.writeHead()`]: #http2_response_writehead_statuscode_statusmessage_headers
3168+
[`tls.Server.close()`]: tls.html#tls_server_close_callback
31423169
[`tls.TLSSocket`]: tls.html#tls_class_tls_tlssocket
31433170
[`tls.connect()`]: tls.html#tls_tls_connect_options_callback
31443171
[`tls.createServer()`]: tls.html#tls_tls_createserver_options_secureconnectionlistener

0 commit comments

Comments
 (0)