File tree Expand file tree Collapse file tree 1 file changed +22
-21
lines changed Expand file tree Collapse file tree 1 file changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -197,6 +197,27 @@ class CorestoreNetworker extends Nanoresource {
197
197
} )
198
198
}
199
199
200
+ async _close ( ) {
201
+ if ( ! this . swarm ) return null
202
+
203
+ for ( const ext of this . _extensions ) {
204
+ ext . destroy ( )
205
+ }
206
+ this . _extensions . clear ( )
207
+
208
+ for ( const stream of this . streams ) {
209
+ stream . destroy ( )
210
+ }
211
+
212
+ return new Promise ( ( resolve , reject ) => {
213
+ this . swarm . destroy ( err => {
214
+ if ( err ) return reject ( err )
215
+ this . swarm = null
216
+ return resolve ( )
217
+ } )
218
+ } )
219
+ }
220
+
200
221
listen ( ) {
201
222
return this . open ( )
202
223
}
@@ -213,7 +234,7 @@ class CorestoreNetworker extends Nanoresource {
213
234
async configure ( discoveryKey , opts = { } ) {
214
235
if ( this . swarm && this . swarm . destroyed ) return null
215
236
if ( ! this . swarm ) {
216
- this . listen ( )
237
+ await this . listen ( )
217
238
return this . configure ( discoveryKey , opts )
218
239
}
219
240
const self = this
@@ -255,26 +276,6 @@ class CorestoreNetworker extends Nanoresource {
255
276
return ext
256
277
}
257
278
258
- async _close ( ) {
259
- if ( ! this . swarm ) return null
260
-
261
- for ( const ext of this . _extensions ) {
262
- ext . destroy ( )
263
- }
264
- this . _extensions . clear ( )
265
-
266
- for ( const stream of this . streams ) {
267
- stream . destroy ( )
268
- }
269
-
270
- return new Promise ( ( resolve , reject ) => {
271
- this . swarm . destroy ( err => {
272
- if ( err ) return reject ( err )
273
- this . swarm = null
274
- return resolve ( )
275
- } )
276
- } )
277
- }
278
279
}
279
280
280
281
module . exports = CorestoreNetworker
You can’t perform that action at this time.
0 commit comments