fix: close previous EventSource before starting new sync job
All checks were successful
Deploy / deploy (push) Successful in 12s
All checks were successful
Deploy / deploy (push) Successful in 12s
Prevents output from a previous run bleeding into the next panel when two sync operations are triggered in quick succession. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
4
webui.py
4
webui.py
@@ -385,7 +385,9 @@ async function refreshStats() {
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
let _activeSrc = null;
|
||||
async function doSync(endpoint, label) {
|
||||
if (_activeSrc) { _activeSrc.close(); _activeSrc = null; }
|
||||
const btn = event.currentTarget;
|
||||
btn.disabled = true;
|
||||
const r = await fetch(endpoint, {method:'POST'});
|
||||
@@ -400,6 +402,7 @@ async function doSync(endpoint, label) {
|
||||
panel.style.display = 'block';
|
||||
panel.innerHTML = '<div class="ln">' + label + '…</div>';
|
||||
const src = new EventSource('/stream/' + d.job_id);
|
||||
_activeSrc = src;
|
||||
src.onmessage = e => {
|
||||
const ev = JSON.parse(e.data);
|
||||
if (ev.type === 'done') {
|
||||
@@ -409,6 +412,7 @@ async function doSync(endpoint, label) {
|
||||
panel.appendChild(div);
|
||||
panel.scrollTop = panel.scrollHeight;
|
||||
src.close();
|
||||
_activeSrc = null;
|
||||
btn.disabled = false;
|
||||
refreshStats();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user