Skip to content

Commit 9bdbe46

Browse files
fix: handle unparsable peer ids (#118)
* deps(dev): bump aegir from 42.2.11 to 43.0.1 Bumps [aegir](https://github.com/ipfs/aegir) from 42.2.11 to 43.0.1. - [Release notes](https://github.com/ipfs/aegir/releases) - [Changelog](https://github.com/ipfs/aegir/blob/master/CHANGELOG.md) - [Commits](ipfs/aegir@v42.2.11...v43.0.1) --- updated-dependencies: - dependency-name: aegir dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * chore: fix tests --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: achingbrain <[email protected]>
1 parent bfbba0f commit 9bdbe46

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"docs:no-publish": "aegir docs --publish false"
3737
},
3838
"devDependencies": {
39-
"aegir": "^42.2.0",
39+
"aegir": "^43.0.1",
4040
"npm-run-all": "^4.1.5"
4141
},
4242
"type": "module",

packages/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
},
6262
"devDependencies": {
6363
"@libp2p/peer-id-factory": "^4.0.4",
64-
"aegir": "^42.2.0",
64+
"aegir": "^43.0.1",
6565
"body-parser": "^1.20.2",
6666
"it-all": "^3.0.2"
6767
},

packages/client/src/client.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -301,24 +301,28 @@ export class DefaultDelegatedRoutingV1HttpApiClient implements DelegatedRoutingV
301301
}
302302

303303
#conformToPeerSchema (record: any): PeerRecord | undefined {
304-
const protocols: string[] = []
305-
const multiaddrs: Multiaddr[] = record.Addrs?.map(multiaddr) ?? []
304+
try {
305+
const protocols: string[] = []
306+
const multiaddrs: Multiaddr[] = record.Addrs?.map(multiaddr) ?? []
306307

307-
if (record.Protocols != null) {
308-
protocols.push(...record.Protocols)
309-
}
308+
if (record.Protocols != null) {
309+
protocols.push(...record.Protocols)
310+
}
310311

311-
if (record.Protocol != null) {
312-
protocols.push(record.Protocol)
313-
delete record.Protocol
314-
}
312+
if (record.Protocol != null) {
313+
protocols.push(record.Protocol)
314+
delete record.Protocol
315+
}
315316

316-
return {
317-
...record,
318-
Schema: 'peer',
319-
ID: peerIdFromString(record.ID),
320-
Addrs: multiaddrs,
321-
Protocols: protocols
317+
return {
318+
...record,
319+
Schema: 'peer',
320+
ID: peerIdFromString(record.ID),
321+
Addrs: multiaddrs,
322+
Protocols: protocols
323+
}
324+
} catch (err) {
325+
log.error('could not conform record to peer schema', err)
322326
}
323327
}
324328
}

packages/interop/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
"@helia/delegated-routing-v1-http-api-client": "^3.0.0",
4242
"@helia/delegated-routing-v1-http-api-server": "^3.0.0",
4343
"@helia/ipns": "^7.1.0",
44-
"@libp2p/identify": "^1.0.10",
44+
"@libp2p/identify": "^2.1.0",
4545
"@libp2p/interface": "^1.1.1",
4646
"@libp2p/kad-dht": "^12.0.3",
4747
"@libp2p/peer-id-factory": "^4.0.4",
48-
"aegir": "^42.2.0",
48+
"aegir": "^43.0.1",
4949
"fastify": "^4.17.0",
5050
"helia": "^4.0.0",
5151
"ipns": "^9.0.0",

packages/interop/test/index.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ describe('delegated-routing-v1-http-api interop', () => {
6363
const cid = CID.createV1(raw.code, digest)
6464

6565
await network[1].blockstore.put(cid, input)
66+
await network[1].routing.provide(cid)
6667

6768
let foundProvider = false
6869

packages/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"@libp2p/peer-id-factory": "^4.0.4",
7878
"@multiformats/multiaddr": "^12.1.3",
7979
"@types/sinon": "^17.0.0",
80-
"aegir": "^42.2.0",
80+
"aegir": "^43.0.1",
8181
"sinon": "^17.0.0",
8282
"sinon-ts": "^2.0.0"
8383
}

0 commit comments

Comments
 (0)