diff --git a/package.json b/package.json index 4508ebad..5eb35c53 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,7 @@ "docs:no-publish": "aegir docs --publish false" }, "dependencies": { - "aegir": "^42.2.3", + "aegir": "^44.1.0", "npm-run-all": "^4.1.5" }, "workspaces": [ diff --git a/packages/libp2p-daemon-client/package.json b/packages/libp2p-daemon-client/package.json index 522c6e4b..e0a38876 100644 --- a/packages/libp2p-daemon-client/package.json +++ b/packages/libp2p-daemon-client/package.json @@ -63,7 +63,7 @@ "@libp2p/daemon-server": "^7.0.0", "@libp2p/interface-compliance-tests": "^5.2.0", "@libp2p/kad-dht": "^12.0.5", - "aegir": "^42.2.3", + "aegir": "^44.1.0", "it-all": "^3.0.4", "it-pipe": "^3.0.1", "sinon": "^18.0.0", diff --git a/packages/libp2p-daemon-client/src/dht.ts b/packages/libp2p-daemon-client/src/dht.ts index 83f46f7d..dc171624 100644 --- a/packages/libp2p-daemon-client/src/dht.ts +++ b/packages/libp2p-daemon-client/src/dht.ts @@ -77,7 +77,7 @@ export class DHT { throw new CodeError(response.error?.msg ?? 'DHT get failed', 'ERR_DHT_GET_FAILED') } - if (response.dht == null || response.dht.value == null) { + if (response.dht?.value == null) { throw new CodeError('Invalid DHT get response', 'ERR_DHT_GET_FAILED') } @@ -108,7 +108,7 @@ export class DHT { throw new CodeError(response.error?.msg ?? 'DHT find peer failed', 'ERR_DHT_FIND_PEER_FAILED') } - if (response.dht == null || response.dht.peer == null || response.dht.peer.addrs == null) { + if (response.dht?.peer?.addrs == null) { throw new CodeError('Invalid response', 'ERR_DHT_FIND_PEER_FAILED') } @@ -178,7 +178,7 @@ export class DHT { } // Stream values - if (dhtResponse.type === DHTResponse.Type.VALUE && dhtResponse.peer != null && dhtResponse.peer?.addrs != null) { + if (dhtResponse.type === DHTResponse.Type.VALUE && dhtResponse.peer?.addrs != null) { yield { id: peerIdFromBytes(dhtResponse.peer.id), multiaddrs: dhtResponse.peer.addrs.map((a) => multiaddr(a)) diff --git a/packages/libp2p-daemon-client/src/index.ts b/packages/libp2p-daemon-client/src/index.ts index d7b3e159..6383a653 100644 --- a/packages/libp2p-daemon-client/src/index.ts +++ b/packages/libp2p-daemon-client/src/index.ts @@ -117,7 +117,7 @@ class Client implements DaemonClient { throw new CodeError(response.error?.msg ?? 'Identify failed', 'ERR_IDENTIFY_FAILED') } - if (response.identify == null || response.identify.addrs == null) { + if (response.identify?.addrs == null) { throw new CodeError('Invalid response', 'ERR_IDENTIFY_FAILED') } @@ -211,6 +211,9 @@ class Client implements DaemonClient { // @ts-expect-error because we are using a passthrough upgrader, this is a MultiaddrConnection await handler(sh.rest()) }) + .catch(err => { + connection.abort(err) + }) .finally(() => { connection.close() .catch(err => { diff --git a/packages/libp2p-daemon-client/src/pubsub.ts b/packages/libp2p-daemon-client/src/pubsub.ts index df5f96c3..d14a6655 100644 --- a/packages/libp2p-daemon-client/src/pubsub.ts +++ b/packages/libp2p-daemon-client/src/pubsub.ts @@ -37,7 +37,7 @@ export class Pubsub { throw new CodeError(response.error?.msg ?? 'Pubsub get topics failed', 'ERR_PUBSUB_GET_TOPICS_FAILED') } - if (response.pubsub == null || response.pubsub.topics == null) { + if (response.pubsub?.topics == null) { throw new CodeError('Invalid response', 'ERR_PUBSUB_GET_TOPICS_FAILED') } @@ -134,7 +134,7 @@ export class Pubsub { throw new CodeError(response.error?.msg ?? 'Pubsub get subscribers failed', 'ERR_PUBSUB_GET_SUBSCRIBERS_FAILED') } - if (response.pubsub == null || response.pubsub.topics == null) { + if (response.pubsub?.topics == null) { throw new CodeError('Invalid response', 'ERR_PUBSUB_GET_SUBSCRIBERS_FAILED') } diff --git a/packages/libp2p-daemon-protocol/package.json b/packages/libp2p-daemon-protocol/package.json index a7b1f69e..a8a3d030 100644 --- a/packages/libp2p-daemon-protocol/package.json +++ b/packages/libp2p-daemon-protocol/package.json @@ -76,7 +76,7 @@ "uint8arraylist": "^2.4.8" }, "devDependencies": { - "aegir": "^42.2.3", + "aegir": "^44.1.0", "protons": "^7.5.0" } } diff --git a/packages/libp2p-daemon-server/package.json b/packages/libp2p-daemon-server/package.json index fc68a54d..d0f0b672 100644 --- a/packages/libp2p-daemon-server/package.json +++ b/packages/libp2p-daemon-server/package.json @@ -67,7 +67,7 @@ "uint8arrays": "^5.0.1" }, "devDependencies": { - "aegir": "^42.2.3", + "aegir": "^44.1.0", "sinon-ts": "^2.0.0" } } diff --git a/packages/libp2p-daemon-server/src/index.ts b/packages/libp2p-daemon-server/src/index.ts index beb685d2..a7812f74 100644 --- a/packages/libp2p-daemon-server/src/index.ts +++ b/packages/libp2p-daemon-server/src/index.ts @@ -81,7 +81,7 @@ export class Server implements Libp2pServer { * Connects the daemons libp2p node to the peer provided */ async connect (request: Request): Promise { - if (request.connect == null || request.connect.addrs == null) { + if (request.connect?.addrs == null) { throw new Error('Invalid request') } @@ -102,7 +102,7 @@ export class Server implements Libp2pServer { * Opens a stream on one of the given protocols to the given peer */ async openStream (request: Request): Promise { - if (request.streamOpen == null || request.streamOpen.proto == null) { + if (request.streamOpen?.proto == null) { throw new Error('Invalid request') } @@ -135,7 +135,7 @@ export class Server implements Libp2pServer { * is registered at the path, it will be overridden. */ async registerStreamHandler (request: Request): Promise { - if (request.streamHandler == null || request.streamHandler.proto == null) { + if (request.streamHandler?.proto == null) { throw new Error('Invalid request') } diff --git a/packages/libp2p-daemon/package.json b/packages/libp2p-daemon/package.json index 742ad8f5..56ca76c5 100644 --- a/packages/libp2p-daemon/package.json +++ b/packages/libp2p-daemon/package.json @@ -58,7 +58,7 @@ "yargs-promise": "^1.1.0" }, "devDependencies": { - "aegir": "^42.2.3", + "aegir": "^44.1.0", "sinon": "^18.0.0" } }