mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 21:42:58 +00:00
fix: fluid streaming was "pausing" when tab was not visible
This commit is contained in:
parent
f070e8b7f9
commit
ed9e99e946
@ -73,7 +73,11 @@ async function* streamLargeDeltasAsRandomChunks(
|
|||||||
const chunkSize = Math.min(Math.floor(Math.random() * 3) + 1, content.length);
|
const chunkSize = Math.min(Math.floor(Math.random() * 3) + 1, content.length);
|
||||||
const chunk = content.slice(0, chunkSize);
|
const chunk = content.slice(0, chunkSize);
|
||||||
yield { done: false, value: chunk };
|
yield { done: false, value: chunk };
|
||||||
|
// Do not sleep if the tab is hidden
|
||||||
|
// Timers are throttled to 1s in hidden tabs
|
||||||
|
if (document?.visibilityState !== 'hidden') {
|
||||||
await sleep(5);
|
await sleep(5);
|
||||||
|
}
|
||||||
content = content.slice(chunkSize);
|
content = content.slice(chunkSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user