@@ -4,7 +4,6 @@ import type { ContextTimed } from '@matrixai/contexts';
44import type KeyRing from '../keys/KeyRing' ;
55import type { Host , Hostname , Port } from '../network/types' ;
66import type NodeGraph from './NodeGraph' ;
7- import type TaskManager from '../tasks/TaskManager' ;
87import type {
98 NodeAddress ,
109 NodeData ,
@@ -69,7 +68,6 @@ class NodeConnectionManager {
6968 protected logger : Logger ;
7069 protected nodeGraph : NodeGraph ;
7170 protected keyRing : KeyRing ;
72- protected taskManager : TaskManager ;
7371 protected quicSocket : QUICSocket ;
7472 // NodeManager has to be passed in during start to allow co-dependency
7573 protected nodeManager : NodeManager | undefined ;
@@ -98,7 +96,6 @@ class NodeConnectionManager {
9896 public constructor ( {
9997 keyRing,
10098 nodeGraph,
101- taskManager,
10299 quicSocket,
103100 quicClientConfig,
104101 seedNodes = { } ,
@@ -110,7 +107,6 @@ class NodeConnectionManager {
110107 } : {
111108 nodeGraph : NodeGraph ;
112109 keyRing : KeyRing ;
113- taskManager : TaskManager ;
114110 quicSocket : QUICSocket ;
115111 quicClientConfig : QUICClientConfig ;
116112 seedNodes ?: SeedNodes ;
@@ -123,7 +119,6 @@ class NodeConnectionManager {
123119 this . logger = logger ?? new Logger ( NodeConnectionManager . name ) ;
124120 this . keyRing = keyRing ;
125121 this . nodeGraph = nodeGraph ;
126- this . taskManager = taskManager ;
127122 this . quicSocket = quicSocket ;
128123 this . quicClientConfig = quicClientConfig ;
129124 const localNodeIdEncoded = nodesUtils . encodeNodeId ( keyRing . getNodeId ( ) ) ;
@@ -154,12 +149,17 @@ class NodeConnectionManager {
154149 public async stop ( ) {
155150 this . logger . info ( `Stopping ${ this . constructor . name } ` ) ;
156151 this . nodeManager = undefined ;
152+ const destroyProms : Array < Promise < void > > = [ ] ;
157153 for ( const [ nodeId , connAndLock ] of this . connections ) {
158154 if ( connAndLock == null ) continue ;
159155 if ( connAndLock . connection == null ) continue ;
160156 // It exists so we want to destroy it
161- await this . destroyConnection ( IdInternal . fromString < NodeId > ( nodeId ) ) ;
157+ const destroyProm = this . destroyConnection (
158+ IdInternal . fromString < NodeId > ( nodeId ) ,
159+ ) ;
160+ destroyProms . push ( destroyProm ) ;
162161 }
162+ await Promise . all ( destroyProms ) ;
163163 this . logger . info ( `Stopped ${ this . constructor . name } ` ) ;
164164 }
165165
0 commit comments