Skip to content

Commit 6f3ebb8

Browse files
cjihrigtargos
authored andcommitted
doc: clarify http2 server.close() behavior
This commit is an attempt to clarify the behavior of HTTP2's server.close() method. Specifically, this makes it more clear that the server stops allowing new sessions although the callback may not be invoked for some time due to previously existing sessions. PR-URL: #28581 Fixes: #28214 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 2205818 commit 6f3ebb8

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

doc/api/http2.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,11 +1748,14 @@ added: v8.4.0
17481748
-->
17491749
* `callback` {Function}
17501750

1751-
Stops the server from accepting new connections. See [`net.Server.close()`][].
1751+
Stops the server from establishing new sessions. This does not prevent new
1752+
request streams from being created due to the persistent nature of HTTP/2
1753+
sessions. To gracefully shut down the server, call [`http2session.close()`] on
1754+
all active sessions.
17521755

1753-
This is not analogous to restricting new requests since HTTP/2
1754-
connections are persistent. To achieve a similar graceful shutdown behavior,
1755-
consider also using [`http2session.close()`] on active sessions.
1756+
If `callback` is provided, it is not invoked until all active sessions have been
1757+
closed, although the server has already stopped allowing new sessions. See
1758+
[`net.Server.close()`][] for more details.
17561759

17571760
#### server.setTimeout([msecs][, callback])
17581761
<!-- YAML
@@ -1893,11 +1896,14 @@ added: v8.4.0
18931896
-->
18941897
* `callback` {Function}
18951898

1896-
Stops the server from accepting new connections. See [`tls.Server.close()`][].
1899+
Stops the server from establishing new sessions. This does not prevent new
1900+
request streams from being created due to the persistent nature of HTTP/2
1901+
sessions. To gracefully shut down the server, call [`http2session.close()`] on
1902+
all active sessions.
18971903

1898-
This is not analogous to restricting new requests since HTTP/2
1899-
connections are persistent. To achieve a similar graceful shutdown behavior,
1900-
consider also using [`http2session.close()`] on active sessions.
1904+
If `callback` is provided, it is not invoked until all active sessions have been
1905+
closed, although the server has already stopped allowing new sessions. See
1906+
[`tls.Server.close()`][] for more details.
19011907

19021908
#### server.setTimeout([msecs][, callback])
19031909
<!-- YAML

0 commit comments

Comments
 (0)