Skip to content

Commit 6aabde3

Browse files
committed
assert in stuck function also
1 parent e2ff259 commit 6aabde3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/replicator.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const ReceiverQueue = require('./receiver-queue')
3030
const HotswapQueue = require('./hotswap-queue')
3131
const RemoteBitfield = require('./remote-bitfield')
3232
const { MerkleTree } = require('./merkle-tree')
33-
const { REQUEST_CANCELLED, REQUEST_TIMEOUT, INVALID_CAPABILITY, SNAPSHOT_NOT_AVAILABLE } = require('hypercore-errors')
33+
const { REQUEST_CANCELLED, REQUEST_TIMEOUT, INVALID_CAPABILITY, SNAPSHOT_NOT_AVAILABLE, ASSERTION } = require('hypercore-errors')
3434
const m = require('./messages')
3535
const caps = require('./caps')
3636

@@ -1240,8 +1240,14 @@ class Peer {
12401240

12411241
let span = 2
12421242
let length = 0
1243+
let cnt = 0
12431244

12441245
while (true) {
1246+
if (++cnt >= 1024) {
1247+
throw ASSERTION('_hasTreeParent is stuck, index=' + index + ', length=' + length +
1248+
', span=' + span + ', remoteLength=' + this.remoteLength + ', length=' + this.core.state.length)
1249+
}
1250+
12451251
ite.parent()
12461252

12471253
const left = (ite.index - ite.factor / 2 + 1) / 2

0 commit comments

Comments
 (0)