Fix (typeof stepUpdate !== 'object') not completing the task on stop.

This commit is contained in:
Marc-Andre Ferland 2022-12-10 00:50:37 -05:00
parent e3184622e8
commit 83e5410945

View File

@ -605,10 +605,11 @@ function onTaskErrorHandler(task, reqBody, instance, reason) {
}
function onTaskCompleted(task, reqBody, instance, outputContainer, stepUpdate) {
if (typeof stepUpdate !== 'object') {
return
}
if (stepUpdate.status !== 'succeeded') {
if (typeof stepUpdate === 'object') {
if (stepUpdate.status === 'succeeded') {
showImages(reqBody, stepUpdate, outputContainer, false)
} else {
task.isProcessing = false
const outputMsg = task['outputMsg']
let msg = ''
if ('detail' in stepUpdate && typeof stepUpdate.detail === 'string' && stepUpdate.detail.length > 0) {
@ -625,9 +626,8 @@ function onTaskCompleted(task, reqBody, instance, outputContainer, stepUpdate) {
msg = `Unexpected Read Error:<br/><pre>StepUpdate: ${JSON.stringify(stepUpdate, undefined, 4)}</pre>`
}
logError(msg, stepUpdate, outputMsg)
return false
}
showImages(reqBody, stepUpdate, outputContainer, false)
}
if (task.isProcessing && task.batchesDone < task.batchCount) {
task['taskStatusLabel'].innerText = "Pending"
task['taskStatusLabel'].classList.add('waitingTaskLabel')
@ -638,8 +638,6 @@ function onTaskCompleted(task, reqBody, instance, outputContainer, stepUpdate) {
return
}
setStatus('request', 'done', 'success')
task.isProcessing = false
task['stopTask'].innerHTML = '<i class="fa-solid fa-trash-can"></i> Remove'
task['taskStatusLabel'].style.display = 'none'