Skip to content

Commit bb8a180

Browse files
committed
fix: adding catch handler to prevent promise rejection leaks
1 parent 4e541c3 commit bb8a180

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/nodes/NodeConnectionManager.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,8 @@ class NodeConnectionManager {
12431243
});
12441244
},
12451245
);
1246+
// Prevent promise rejection leak
1247+
void holePunchAttempt.catch(() => {});
12461248
this.activeHolePunchPs.set(id, holePunchAttempt);
12471249
}
12481250

@@ -1299,7 +1301,7 @@ class NodeConnectionManager {
12991301
this.keyRing.keyPair,
13001302
data,
13011303
);
1302-
const connProm = this.withConnF(targetNodeId, async (conn) => {
1304+
const connectionSignalP = this.withConnF(targetNodeId, async (conn) => {
13031305
const client = conn.getClient();
13041306
await client.methods.nodesConnectionSignalFinal({
13051307
sourceNodeIdEncoded: nodesUtils.encodeNodeId(sourceNodeId),
@@ -1325,9 +1327,11 @@ class NodeConnectionManager {
13251327
},
13261328
)
13271329
.finally(() => {
1328-
this.activeSignalFinalPs.delete(connProm);
1330+
this.activeSignalFinalPs.delete(connectionSignalP);
13291331
});
1330-
this.activeSignalFinalPs.add(connProm);
1332+
// Preventing promise rejection leak.
1333+
connectionSignalP.catch(() => {});
1334+
this.activeSignalFinalPs.add(connectionSignalP);
13311335
return {
13321336
host,
13331337
port,

src/nodes/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ function isConnectionError(e): boolean {
323323
e instanceof quicErrors.ErrorQUICConnectionPeer ||
324324
e instanceof quicErrors.ErrorQUICConnectionLocal ||
325325
e instanceof quicErrors.ErrorQUICConnectionNotRunning ||
326-
e instanceof quicErrors.ErrorQUICConnectionStopping
326+
e instanceof quicErrors.ErrorQUICConnectionStopping ||
327+
e instanceof quicErrors.ErrorQUICConnectionIdleTimeout
327328
);
328329
}
329330

0 commit comments

Comments
 (0)