mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-01-11 16:58:31 +01:00
Hotfix for batched-up chunked responses
This commit is contained in:
parent
37cf9eb587
commit
688659b815
@ -210,7 +210,7 @@
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script src="media/main.js?v=3"></script>
|
||||
<script src="media/main.js?v=4"></script>
|
||||
<script>
|
||||
async function init() {
|
||||
await loadModifiers()
|
||||
|
@ -366,6 +366,20 @@ async function doMakeImage(reqBody, batchCount) {
|
||||
res = undefined
|
||||
progressBar.style.display = 'none'
|
||||
} else {
|
||||
if (finalJSON !== undefined && finalJSON.indexOf('}{') !== -1) {
|
||||
// hack for a middleman buffering all the streaming updates, and unleashing them
|
||||
// on the poor browser in one shot.
|
||||
// this results in having to parse JSON like {"step": 1}{"step": 2}...{"status": "succeeded"..}
|
||||
// which is obviously invalid.
|
||||
// So we need to just extract the last {} section, starting from "status" to the end of the response
|
||||
|
||||
let lastChunkIdx = finalJSON.lastIndexOf('}{')
|
||||
if (lastChunkIdx !== -1) {
|
||||
let remaining = finalJSON.substring(lastChunkIdx)
|
||||
finalJSON = remaining.substring(1)
|
||||
}
|
||||
}
|
||||
|
||||
res = JSON.parse(finalJSON)
|
||||
progressBar.style.display = 'none'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user