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 97a58c5

Browse filesBrowse files
atlowChemiRafaelGSS
authored andcommitted
https: 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 5378ad8 commit 97a58c5
Copy full SHA for 97a58c5

File tree

Expand file treeCollapse file tree

3 files changed

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

3 files changed

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

‎doc/api/https.md‎

Copy file name to clipboardExpand all lines: doc/api/https.md
+12Lines changed: 12 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ added: v0.1.90
135135

136136
See [`server.close()`][] in the `node:http` module.
137137

138+
### `server[Symbol.asyncDispose]()`
139+
140+
<!-- YAML
141+
added: REPLACEME
142+
-->
143+
144+
> Stability: 1 - Experimental
145+
146+
Calls [`server.close()`][httpsServerClose] and returns a promise that
147+
fulfills when the server has closed.
148+
138149
### `server.closeAllConnections()`
139150

140151
<!-- YAML
@@ -571,4 +582,5 @@ headers: max-age=0; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; p
571582
[`tls.connect()`]: tls.md#tlsconnectoptions-callback
572583
[`tls.createSecureContext()`]: tls.md#tlscreatesecurecontextoptions
573584
[`tls.createServer()`]: tls.md#tlscreateserveroptions-secureconnectionlistener
585+
[httpsServerClose]: #serverclosecallback
574586
[sni wiki]: https://en.wikipedia.org/wiki/Server_Name_Indication
Collapse file

‎lib/https.js‎

Copy file name to clipboardExpand all lines: lib/https.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ const {
3333
ObjectSetPrototypeOf,
3434
ReflectApply,
3535
ReflectConstruct,
36+
SymbolAsyncDispose,
3637
} = primordials;
3738

3839
const {
3940
assertCrypto,
4041
kEmptyObject,
42+
promisify,
4143
} = require('internal/util');
4244
assertCrypto();
4345

@@ -110,6 +112,10 @@ Server.prototype.close = function() {
110112
ReflectApply(tls.Server.prototype.close, this, arguments);
111113
};
112114

115+
Server.prototype[SymbolAsyncDispose] = async function() {
116+
return FunctionPrototypeCall(promisify(this.close), this);
117+
};
118+
113119
/**
114120
* Creates a new `https.Server` instance.
115121
* @param {{
Collapse file
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
if (!common.hasCrypto)
6+
common.skip('missing crypto');
7+
8+
const assert = require('assert');
9+
const { createServer } = require('https');
10+
const { kConnectionsCheckingInterval } = require('_http_server');
11+
12+
const server = createServer();
13+
14+
server.listen(0, common.mustCall(() => {
15+
server.on('close', common.mustCall());
16+
server[Symbol.asyncDispose]().then(common.mustCall(() => {
17+
assert(server[kConnectionsCheckingInterval]._destroyed);
18+
}));
19+
}));

0 commit comments

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