Commit 7577fd8 1 parent bb04854 commit 7577fd8 Copy full SHA for 7577fd8
File tree 3 files changed +38
-0
lines changed
3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,18 @@ added: v0.1.90
135
135
136
136
See [ ` server.close() ` ] [ ] in the ` node:http ` module.
137
137
138
+
139
+ ### ` server[Symbol.asyncDispose]() `
140
+
141
+ <!-- YAML
142
+ added: REPLACEME
143
+ -->
144
+
145
+ > Stability: 1 - Experimental
146
+
147
+ Calls [ ` server.close() ` ] [ httpsServerClose ] and returns a promise that fulfills when the
148
+ server has closed.
149
+
138
150
### ` server.closeAllConnections() `
139
151
140
152
<!-- YAML
@@ -571,4 +583,5 @@ headers: max-age=0; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; p
571
583
[ `tls.connect()` ] : tls.md#tlsconnectoptions-callback
572
584
[ `tls.createSecureContext()` ] : tls.md#tlscreatesecurecontextoptions
573
585
[ `tls.createServer()` ] : tls.md#tlscreateserveroptions-secureconnectionlistener
586
+ [ httpsServerClose ] : serverclosecallback
574
587
[ sni wiki ] : https://en.wikipedia.org/wiki/Server_Name_Indication
Original file line number Diff line number Diff line change @@ -33,11 +33,13 @@ const {
33
33
ObjectSetPrototypeOf,
34
34
ReflectApply,
35
35
ReflectConstruct,
36
+ SymbolAsyncDispose,
36
37
} = primordials ;
37
38
38
39
const {
39
40
assertCrypto,
40
41
kEmptyObject,
42
+ promisify,
41
43
} = require ( 'internal/util' ) ;
42
44
assertCrypto ( ) ;
43
45
@@ -110,6 +112,10 @@ Server.prototype.close = function() {
110
112
ReflectApply ( tls . Server . prototype . close , this , arguments ) ;
111
113
} ;
112
114
115
+ Server . prototype [ SymbolAsyncDispose ] = async function ( ) {
116
+ return promisify ( this . close ) . call ( this ) ;
117
+ } ;
118
+
113
119
/**
114
120
* Creates a new `https.Server` instance.
115
121
* @param {{
Original file line number Diff line number Diff line change
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
+ } ) ) ;
You can’t perform that action at this time.
0 commit comments