hypercore 10.37.19 → 10.37.21

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 (2) hide show
  1. package/index.js +9 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -26,7 +26,8 @@ const {
26
26
  BAD_ARGUMENT,
27
27
  SESSION_CLOSED,
28
28
  SESSION_NOT_WRITABLE,
29
- SNAPSHOT_NOT_AVAILABLE
29
+ SNAPSHOT_NOT_AVAILABLE,
30
+ DECODING_ERROR
30
31
  } = require('hypercore-errors')
31
32
 
32
33
  const promises = Symbol.for('hypercore.promises')
@@ -272,9 +273,9 @@ module.exports = class Hypercore extends EventEmitter {
272
273
 
273
274
  setActive (bool) {
274
275
  const active = !!bool
275
- if (active === this._active) return
276
+ if (active === this._active || this.closing) return
276
277
  this._active = active
277
- if (!this.opened || this.closing) return
278
+ if (!this.opened) return
278
279
  this.replicator.updateActivity(this._active ? 1 : -1)
279
280
  }
280
281
 
@@ -1108,7 +1109,11 @@ module.exports = class Hypercore extends EventEmitter {
1108
1109
 
1109
1110
  _decode (enc, block) {
1110
1111
  if (this.padding) block = block.subarray(this.padding)
1111
- if (enc) return c.decode(enc, block)
1112
+ try {
1113
+ if (enc) return c.decode(enc, block)
1114
+ } catch {
1115
+ throw DECODING_ERROR()
1116
+ }
1112
1117
  return block
1113
1118
  }
1114
1119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.37.19",
3
+ "version": "10.37.21",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {