hypercore 11.27.3 → 11.27.5

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.
@@ -583,12 +583,20 @@ class SessionState {
583
583
  continue
584
584
  }
585
585
 
586
- await new Promise((resolve) => setTimeout(resolve, 8000))
586
+ let restart = false
587
587
 
588
- peers = getRecoveryPeers(replicator.peers)
588
+ for (let i = 0; i < 32; i++) {
589
+ await new Promise((resolve) => setTimeout(resolve, 250))
589
590
 
590
- if (peers.length < 1 || this.closing) continue
591
- if (peers[0].remoteLength > this.length) continue
591
+ peers = getRecoveryPeers(replicator.peers)
592
+
593
+ if (this.closing || !validateRecoveryPeers(peers, this.length)) {
594
+ restart = true
595
+ break
596
+ }
597
+ }
598
+
599
+ if (restart) continue
592
600
 
593
601
  if (this.length !== length) {
594
602
  throw SESSION_NOT_WRITABLE('core recovered during append')
@@ -1310,3 +1318,14 @@ function getRecoveryPeers(peers) {
1310
1318
 
1311
1319
  return actual
1312
1320
  }
1321
+
1322
+ function validateRecoveryPeers(peers, length) {
1323
+ if (peers.length < 1) return false
1324
+
1325
+ for (const p of peers) {
1326
+ if (p.remoteLength > length) return false
1327
+ if (p.remoteLength === 0) return false
1328
+ }
1329
+
1330
+ return true
1331
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.27.3",
3
+ "version": "11.27.5",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {