Merge pull request #375 from madrang/beta

Improved render response checks
This commit is contained in:
cmdr2 2022-10-22 22:23:05 +05:30 committed by GitHub
commit 5568a09f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -522,7 +522,7 @@ async function doMakeImage(task) {
if (typeof renderRequest?.stream !== 'string') {
console.log('Endpoint response: ', renderRequest)
throw new Error('Endpoint response does not contains a response stream url.')
throw new Error(renderRequest.detail || 'Endpoint response does not contains a response stream url.')
}
task['taskStatusLabel'].innerText = "Waiting"
@ -536,12 +536,23 @@ async function doMakeImage(task) {
}
} while (Date.now() < (serverState.time + SERVER_STATE_VALIDITY_DURATION) && serverState.task !== renderRequest.task)
if (serverState.session !== 'pending' && serverState.session !== 'running' && serverState.session !== 'buffer') {
if (serverState.session === 'stopped') {
switch(serverState.session) {
case 'pending':
case 'running':
case 'buffer':
// Normal expected messages.
break
case 'completed':
console.warn('Server %o render request %o completed unexpectedly', serverState, renderRequest)
break // Continue anyway to try to read cached result.
case 'error':
console.error('Server %o render request %o has failed', serverState, renderRequest)
break // Still valid, Update UI with error message
case 'stopped':
console.log('Server %o render request %o was stopped', serverState, renderRequest)
return false
}
throw new Error('Unexpected server task state: ' + serverState.session || 'Undefined')
default:
throw new Error('Unexpected server task state: ' + serverState.session || 'Undefined')
}
while (serverState.task === renderRequest.task && serverState.session === 'pending') {