Browse Source

fix query requests after dht destruction

session-estimator
Mathias Buus 3 years ago
parent
commit
7ec0a69f49
  1. 1
      index.js
  2. 4
      lib/query.js

1
index.js

@ -199,6 +199,7 @@ class DHT extends EventEmitter {
_request (to, command, target, value, onresponse, onerror) {
const req = this.io.createRequest(to, null, command, target, value)
if (req === null) return null
req.onresponse = onresponse
req.onerror = onerror

4
lib/query.js

@ -311,6 +311,10 @@ module.exports = class Query extends Readable {
this.inflight++
const req = this.dht._request(to, this.command, this.target, this.value, this._onvisitbound, this._onerrorbound)
if (req === null) {
this.destroy(new Error('Node was destroyed'))
return
}
req.oncycle = this._oncyclebound
}
}

Loading…
Cancel
Save