Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5378ad8

Browse filesBrowse files
atlowChemiRafaelGSS
authored andcommitted
http2: server add asyncDispose
PR-URL: #48548 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 94ebb02 commit 5378ad8
Copy full SHA for 5378ad8

File tree

Expand file treeCollapse file tree

3 files changed

+32
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+32
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/http2.md‎

Copy file name to clipboardExpand all lines: doc/api/http2.md
+12Lines changed: 12 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2070,6 +2070,17 @@ If `callback` is provided, it is not invoked until all active sessions have been
20702070
closed, although the server has already stopped allowing new sessions. See
20712071
[`net.Server.close()`][] for more details.
20722072

2073+
#### `server[Symbol.asyncDispose]()`
2074+
2075+
<!-- YAML
2076+
added: REPLACEME
2077+
-->
2078+
2079+
> Stability: 1 - Experimental
2080+
2081+
Calls [`server.close()`][] and returns a promise that fulfills when the
2082+
server has closed.
2083+
20732084
#### `server.setTimeout([msecs][, callback])`
20742085

20752086
<!-- YAML
@@ -4226,6 +4237,7 @@ you need to implement any fall-back behavior yourself.
42264237
[`response.write(data, encoding)`]: http.md#responsewritechunk-encoding-callback
42274238
[`response.writeContinue()`]: #responsewritecontinue
42284239
[`response.writeHead()`]: #responsewriteheadstatuscode-statusmessage-headers
4240+
[`server.close()`]: #serverclosecallback
42294241
[`server.maxHeadersCount`]: http.md#servermaxheaderscount
42304242
[`tls.Server.close()`]: tls.md#serverclosecallback
42314243
[`tls.TLSSocket`]: tls.md#class-tlstlssocket
Collapse file

‎lib/internal/http2/core.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/core.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const {
2626
SafeSet,
2727
StringPrototypeSlice,
2828
Symbol,
29+
SymbolAsyncDispose,
2930
TypedArrayPrototypeGetLength,
3031
Uint32Array,
3132
Uint8Array,
@@ -3189,6 +3190,10 @@ class Http2Server extends NETServer {
31893190
validateSettings(settings);
31903191
this[kOptions].settings = { ...this[kOptions].settings, ...settings };
31913192
}
3193+
3194+
async [SymbolAsyncDispose]() {
3195+
return FunctionPrototypeCall(promisify(super.close), this);
3196+
}
31923197
}
31933198

31943199
Http2Server.prototype[EventEmitter.captureRejectionSymbol] = function(
Collapse file
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
if (!common.hasCrypto)
6+
common.skip('missing crypto');
7+
8+
const http2 = require('http2');
9+
10+
const server = http2.createServer();
11+
12+
server.listen(0, common.mustCall(() => {
13+
server.on('close', common.mustCall());
14+
server[Symbol.asyncDispose]().then(common.mustCall());
15+
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.