hypercore 11.39.2 → 11.39.3

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/lib/replicator.js +10 -4
  2. package/package.json +1 -1
package/lib/replicator.js CHANGED
@@ -1009,6 +1009,8 @@ class Peer {
1009
1009
 
1010
1010
  await this.replicator._txLock.lock()
1011
1011
  try {
1012
+ if (this.replicator.destroyed) return
1013
+
1012
1014
  const remoteLength = Math.max(this.remoteLength, this.pushedLength)
1013
1015
 
1014
1016
  msg.block = {
@@ -1270,7 +1272,7 @@ class Peer {
1270
1272
  return
1271
1273
  }
1272
1274
 
1273
- if (this.core.closed && !isCriticalError(err)) return
1275
+ if ((this.core.closed || this.replicator.destroyed) && !isCriticalError(err)) return
1274
1276
 
1275
1277
  if (err.code !== 'INVALID_OPERATION') {
1276
1278
  // might be a fork, verify
@@ -2203,6 +2205,8 @@ module.exports = class Replicator {
2203
2205
  }
2204
2206
 
2205
2207
  async applyPendingReorg() {
2208
+ if (this.destroyed) return false
2209
+
2206
2210
  if (this._applyingReorg !== null) {
2207
2211
  await this._applyingReorg
2208
2212
  return true
@@ -2498,6 +2502,8 @@ module.exports = class Replicator {
2498
2502
 
2499
2503
  // Runs in the background - not allowed to throw
2500
2504
  async _resolveBlocksLocally() {
2505
+ if (this.destroyed) return
2506
+
2501
2507
  // TODO: check if fork compat etc. Requires that we pass down truncation info
2502
2508
 
2503
2509
  const clear = []
@@ -2946,11 +2952,11 @@ module.exports = class Replicator {
2946
2952
  await this._applyingReorg
2947
2953
  } catch (err) {
2948
2954
  this._upgrade = null
2949
- u.reject(err)
2955
+ if (u !== null) u.reject(err)
2956
+ } finally {
2957
+ this._applyingReorg = null
2950
2958
  }
2951
2959
 
2952
- this._applyingReorg = null
2953
-
2954
2960
  if (this._upgrade !== null) {
2955
2961
  this._resolveUpgradeRequest(null)
2956
2962
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.39.2",
3
+ "version": "11.39.3",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {