libp2p / js-libp2p

The JavaScript Implementation of libp2p networking stack.
https://libp2p.io
Other
2.29k stars 438 forks source link

dht: kadDHT() causes TypeError: Cannot destructure property 'kBucketSize' of 'init' as it is undefined #2381

Closed alexeyvolkoff closed 7 months ago

alexeyvolkoff commented 7 months ago

Description:

Adding dht to libp2p configuration causes crash:

         services: {
            identify: identify(),
            pubsub: gossipsub({ allowPublishToZeroPeers: true }),
            dht: kadDHT()
        }
TypeError: Cannot destructure property 'kBucketSize' of 'init' as it is undefined.
    at new KadDHT (file:///home/alexey/projects/orbit/node_modules/@libp2p/kad-dht/dist/src/kad-dht.js:109:17)
    at file:///home/alexey/projects/orbit/node_modules/@libp2p/kad-dht/dist/src/index.js:115:28
    at new Libp2pNode (file:///home/alexey/projects/orbit/node_modules/libp2p/dist/src/libp2p.js:126:33)
    at createLibp2pNode (file:///home/alexey/projects/orbit/node_modules/libp2p/dist/src/libp2p.js:321:12)
    at async createLibp2p (file:///home/alexey/projects/orbit/node_modules/libp2p/dist/src/index.js:44:18)
    at async main (file:///home/alexey/projects/orbit/index.js:56:20)

Steps to reproduce the error:

Just define dht: kadDHT() in services{}

achingbrain commented 7 months ago

I think this could use a more helpful error message, but as of v12.x.x you need to configure the KadDHT module to tell it about your DHT configuration.

For example, how to connect to the public Amino/IPFS DHT, or how to connect to a local, LAN-only DHT.

github-actions[bot] commented 7 months ago

Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.

github-actions[bot] commented 7 months ago

This issue was closed because it is missing author input.

abuvanth commented 6 months ago

dht: kadDHT({ kBucketSize: 20, }),

should fix issue