Moved done check after data read in 'doMakeImage'.

This commit is contained in:
Marc-Andre Ferland 2022-10-11 16:19:34 -04:00
parent 83b0239791
commit d6d4ce0ac4

View File

@ -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