holepunchto / dht-rpc

Make RPC calls over a Kademlia based DHT.
MIT License
196 stars 37 forks source link

Immediate destroy with empty bootstrap array throws #30

Closed andrewosh closed 3 years ago

andrewosh commented 3 years ago

If you run this from a repl:

const DHT = require('dht-rpc')
const node = new DHT({ bootstrap: [] }); node.destroy()

It will produce the following error:

> (node:2432030) UnhandledPromiseRejectionWarning: Error [ERR_SOCKET_DGRAM_NOT_RUNNING]: Not running
    at healthCheck (dgram.js:897:11)
    at Socket.bind (dgram.js:207:3)
    at /home/andrewosh/Development/@hyperswarm/hyperswarm/node_modules/dht-rpc/lib/rpc.js:59:9
    at new Promise (<anonymous>)
    at RPC.bind (/home/andrewosh/Development/@hyperswarm/hyperswarm/node_modules/dht-rpc/lib/rpc.js:56:21)
    at DHT.bootstrap (/home/andrewosh/Development/@hyperswarm/hyperswarm/node_modules/dht-rpc/index.js:197:20)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:2432030) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 5)
mafintosh commented 3 years ago

Thanks! Fixed in latest version