From d1ccc3426ecd6bf2007e166284b1ade2e3758de0 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Wed, 13 Dec 2023 16:08:42 +0200 Subject: [PATCH] fix stream phase 9 when no msgs received --- lib/stream.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/stream.js b/lib/stream.js index e500ef5..58510a1 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -370,10 +370,6 @@ class SyncStream extends Pipeable { // prettier-ignore this.#debug('%s Stream IN9: got %s msgs in %s', this.#myId, msgsForMe.length, id) - const goal = this.#goals.get(id) - if (!goal) throw new Error(`No goal found for "${id}"`) - const localWantRange = this.#localWant.get(id) - if (!localWantRange) throw new Error('local want-range not set') this.#requested.delete(id) this.#localHave.delete(id) this.#localWant.delete(id) @@ -381,7 +377,12 @@ class SyncStream extends Pipeable { this.#remoteWant.delete(id) this.#receivableMsgs.delete(id) this.#sendableMsgs.delete(id) + if (msgsForMe.length === 0) return + const goal = this.#goals.get(id) + if (!goal) throw new Error(`No goal found for "${id}"`) + const localWantRange = this.#localWant.get(id) + if (!localWantRange) throw new Error('local want-range not set') try { this.#algo.commit(id, msgsForMe, goal, localWantRange) } catch (err) {