From d6d4ce0ac4d9ef38184f9034f8fa337bb4385efc Mon Sep 17 00:00:00 2001 From: Marc-Andre Ferland Date: Tue, 11 Oct 2022 16:19:34 -0400 Subject: [PATCH] Moved done check after data read in 'doMakeImage'. --- ui/media/main.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ui/media/main.js b/ui/media/main.js index 6741b570..59bce213 100644 --- a/ui/media/main.js +++ b/ui/media/main.js @@ -491,12 +491,8 @@ async function doMakeImage(task) { let t = new Date().getTime() const {value, done} = await reader.read() - if (done) { - break - } let timeTaken = (prevTime === -1 ? -1 : t - prevTime) - let jsonStr = textDecoder.decode(value) try { // hack for a middleman buffering all the streaming updates, and unleashing them on the poor browser in one shot. @@ -520,6 +516,9 @@ async function doMakeImage(task) { throw e } } + if (done) { + break + } if (typeof stepUpdate === 'object' && 'step' in stepUpdate) { let batchSize = stepUpdate.total_steps let overallStepCount = stepUpdate.step + task.batchesDone * batchSize