dht-rpc 6.3.1 → 6.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/lib/io.js +10 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -131,7 +131,7 @@ For the vast majority of use-cases you should always use adaptive mode to ensure
131
131
 
132
132
  Your DHT routing id is `hash(publicIp + publicPort)` and will be autoconfigured internally.
133
133
 
134
- #### `const node = DHT.bootrapper(port, host, [options])`
134
+ #### `const node = DHT.bootstrapper(port, host, [options])`
135
135
 
136
136
  Make a bootstrap node for your DHT. The port and host needs to be it's globally accessable port and host.
137
137
  Note: `port` and `host` parameters are used to create the node id. Use `options.host` if you want to bind to i.e. 127.0.0.1.
@@ -193,7 +193,7 @@ If your node does not have a consistent port, this is set to 0.
193
193
 
194
194
  Boolean indicated if your node is behind a firewall.
195
195
 
196
- This is auto detected by having other node's trying to do a PING to you
196
+ This is auto detected by having other nodes trying to do a PING to you
197
197
  without you contacting them first.
198
198
 
199
199
  #### `const addr = node.address()`
package/lib/io.js CHANGED
@@ -99,7 +99,11 @@ module.exports = class IO {
99
99
 
100
100
  async destroy () {
101
101
  if (this._destroying) return this._destroying
102
+ this._destroying = this._destroy()
103
+ return this._destroying
104
+ }
102
105
 
106
+ async _destroy () {
103
107
  // simplifies timing to await the bind here also, although it might be unneeded
104
108
  await this.bind()
105
109
 
@@ -117,13 +121,11 @@ module.exports = class IO {
117
121
  req.onerror(errors.createDestroyedError(), req)
118
122
  }
119
123
 
120
- this._destroying = Promise.allSettled([
124
+ await Promise.allSettled([
121
125
  this.serverSocket.close(),
122
126
  this.clientSocket.close(),
123
127
  this.networkInterfaces.destroy()
124
128
  ])
125
-
126
- return this._destroying
127
129
  }
128
130
 
129
131
  bind () {
@@ -304,6 +306,11 @@ class Request {
304
306
  if (this.destroyed) return
305
307
  this.destroyed = true
306
308
 
309
+ if (this._timeout) {
310
+ clearTimeout(this._timeout)
311
+ this._timeout = null
312
+ }
313
+
307
314
  const i = this._io.inflight.indexOf(this)
308
315
  if (i === -1) return
309
316
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dht-rpc",
3
- "version": "6.3.1",
3
+ "version": "6.3.2",
4
4
  "description": "Make RPC calls over a Kademlia based DHT",
5
5
  "main": "index.js",
6
6
  "dependencies": {