Skip to content

Commit 52a3e89

Browse files
committed
Try/catch & pause if updating remote contig hint throws
1 parent 39af9e5 commit 52a3e89

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/replicator.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ class Peer {
11491149
this._clearLocalRange(fixedStart, length)
11501150
}
11511151

1152-
onrange({ drop, start, length }) {
1152+
async onrange({ drop, start, length }) {
11531153
const has = drop === false
11541154

11551155
if (drop === true && start < this._remoteContiguousLength) {
@@ -1159,7 +1159,15 @@ class Peer {
11591159
if (start === 0 && drop === false) {
11601160
if (length > this._remoteContiguousLength) {
11611161
this._remoteContiguousLength = length
1162-
if (this.remoteFork >= this.core.state.fork) this.core.updateRemoteContiguousLength(length)
1162+
if (this.remoteFork >= this.core.state.fork) {
1163+
try {
1164+
await this.core.updateRemoteContiguousLength(length)
1165+
} catch (err) {
1166+
safetyCatch(err)
1167+
this.paused = true
1168+
return
1169+
}
1170+
}
11631171
}
11641172
} else if (length === 1) {
11651173
const bitfield = this.core.skipBitfield === null ? this.core.bitfield : this.core.skipBitfield

0 commit comments

Comments
 (0)