Skip to content

dht.lookup() throws uncatchable error  #224

@phillmac

Description

@phillmac

const q = query.q.toString()

Version 9.0.3
node v14.15.3

The line numbers may have changed a little due to a slightly outdated version , but the above seems to be the referenced line.
Moreover the cause of the error should still be present, because the underlying cause hasn't changed.
The trace is as follows:

/torrent-health-scraper/node_modules/bittorrent-dht/client.js:505
  var q = query.q.toString()
                  ^

TypeError: Cannot read property 'toString' of undefined
    at DHT._onquery (/torrent-health-scraper/node_modules/bittorrent-dht/client.js:505:19)
    at RPC.onquery (/torrent-health-scraper/node_modules/bittorrent-dht/client.js:95:10)
    at RPC.emit (events.js:315:20)
    at RPC.onquery (/torrent-health-scraper/node_modules/k-rpc/index.js:67:10)
    at RPC.emit (events.js:315:20)
    at Socket.onmessage (/torrent-health-scraper/node_modules/k-rpc-socket/index.js:121:12)
    at Socket.emit (events.js:315:20)
    at UDP.onMessage [as onmessage] (dgram.js:919:8)

Possibly this is an error in k-rpc? if the q property should always be present and it somehow isn't.
However imho it seems we could make some improvements here by removing the assumption that everything will always be fine and at least throw a catchable error instead of crashing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions