Skip to content

Commit fd0c31c

Browse files
committed
fix: find node checks findByX errors properly
1 parent 3f6f39a commit fd0c31c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/nodes/NodeManager.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import * as nodesEvents from './events';
5050
import * as nodesErrors from './errors';
5151
import * as agentErrors from './agent/errors';
5252
import NodeConnectionQueue from './NodeConnectionQueue';
53+
import { ErrorNodeManagerFindNodeFailed } from './errors';
5354
import { assertClaimNetworkAuthority } from '../claims/payloads/claimNetworkAuthority';
5455
import { assertClaimNetworkAccess } from '../claims/payloads/claimNetworkAccess';
5556
import Token from '../tokens/Token';
@@ -637,7 +638,14 @@ class NodeManager {
637638
try {
638639
return await Promise.any([findBySignal, findByDirect, findByMDNS]);
639640
} catch (e) {
640-
// FIXME: check error type and throw if not connection related failure
641+
if (e instanceof AggregateError) {
642+
for (const error of e.errors) {
643+
// Checking if each error is an expected error
644+
if (!(error instanceof ErrorNodeManagerFindNodeFailed)) throw e;
645+
}
646+
} else if (!(e instanceof ErrorNodeManagerFindNodeFailed)) {
647+
throw e;
648+
}
641649
return;
642650
} finally {
643651
abortController.abort(abortPendingConnectionsReason);

0 commit comments

Comments
 (0)