File tree 1 file changed +12
-1
lines changed
packages/extension-polkagate/src/util/workers/utils 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -22,14 +22,25 @@ export async function fastestEndpoint (endpoints) {
22
22
23
23
return {
24
24
connection,
25
+ connectionEndpoint : value ,
25
26
wsProvider
26
27
} ;
27
28
} ) . filter ( ( i ) => ! ! i ) ;
28
29
29
30
const api = await Promise . any ( connections . map ( ( { connection } ) => connection ) ) ;
30
31
32
+ // Find the matching connection that created this API
33
+ // @ts -ignore
34
+ const notConnectedEndpoint = connections . filter ( ( { connectionEndpoint } ) => connectionEndpoint !== api ?. _options ?. provider ?. endpoint ) ;
35
+ // @ts -ignore
36
+ const connectedEndpoint = connections . find ( ( { connectionEndpoint } ) => connectionEndpoint === api ?. _options ?. provider ?. endpoint ) ;
37
+
38
+ notConnectedEndpoint . forEach ( ( { wsProvider } ) => {
39
+ wsProvider . disconnect ( ) . catch ( ( ) => null ) ;
40
+ } ) ;
41
+
31
42
return {
32
43
api,
33
- connections
44
+ connections : connectedEndpoint ? [ connectedEndpoint ] : [ ]
34
45
} ;
35
46
}
You can’t perform that action at this time.
0 commit comments