File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ import { selectConnection } from "@waku/utils/libp2p";
6
6
import debug from "debug" ;
7
7
8
8
export class StreamManager {
9
- private streamPool : Map < string , Promise < Stream > > ;
10
- private log : debug . Debugger ;
9
+ private streamPool : Map < string , Promise < Stream | void > > ;
10
+ private readonly log : debug . Debugger ;
11
11
12
12
constructor (
13
13
public multicodec : string ,
@@ -38,7 +38,7 @@ export class StreamManager {
38
38
39
39
const stream = await streamPromise ;
40
40
41
- if ( stream . status === "closed" ) {
41
+ if ( ! stream || stream . status === "closed" ) {
42
42
return this . newStream ( peer ) ; // fallback by creating a new stream on the spot
43
43
}
44
44
@@ -55,7 +55,10 @@ export class StreamManager {
55
55
}
56
56
57
57
private prepareNewStream ( peer : Peer ) : void {
58
- const streamPromise = this . newStream ( peer ) ;
58
+ const streamPromise = this . newStream ( peer ) . catch ( ( ) => {
59
+ // No error thrown as this call is not triggered by the user
60
+ this . log ( `Failed to prepare a new stream for ${ peer . id . toString ( ) } ` ) ;
61
+ } ) ;
59
62
this . streamPool . set ( peer . id . toString ( ) , streamPromise ) ;
60
63
}
61
64
You can’t perform that action at this time.
0 commit comments