e.message wont start with 'JSON.parse' on mobile.

Removed message check but made the try/catch more narrow to not hide other errors.
This commit is contained in:
Marc-Andre Ferland 2022-10-11 13:48:18 -04:00
parent 3abd570678
commit d1fa13d67a

View File

@ -497,11 +497,17 @@ async function doMakeImage(task) {
let timeTaken = (prevTime === -1 ? -1 : t - prevTime)
let jsonStr = textDecoder.decode(value)
let stepUpdate = undefined
try {
let stepUpdate = JSON.parse(jsonStr)
if (stepUpdate.step === undefined) {
stepUpdate = JSON.parse(jsonStr)
} catch (e) {
if (e instanceof SyntaxError) {
finalJSON += jsonStr
} else {
throw e
}
}
if (!stepUpdate || stepUpdate.step === undefined) {
finalJSON += jsonStr
} else {
let batchSize = stepUpdate.total_steps
@ -526,13 +532,6 @@ async function doMakeImage(task) {
showImages(reqBody, stepUpdate, outputContainer, true)
}
}
} catch (e) {
if (e instanceof SyntaxError && e.message.startsWith('JSON.parse')) {
finalJSON += jsonStr
} else {
throw e
}
}
prevTime = t
} catch (e) {