From 93d84e3b9c21126b6d6a5911a43d924348f9f2df Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Mon, 13 Feb 2023 15:52:34 -0500 Subject: [PATCH] Lower timeout and fix for colab. --- webshit/index.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/webshit/index.html b/webshit/index.html index c3f56afcf..66d096608 100644 --- a/webshit/index.html +++ b/webshit/index.html @@ -480,11 +480,21 @@ document.addEventListener('drop', (event) => { prompt_file_load(file); }); + (() => { function updateStatus(data) { document.getElementById("queuesize").innerHTML = "Queue size: " + (data ? data.exec_info.queue_remaining : "ERR"); } + //fix for colab and other things that don't support websockets. + function manually_fetch_queue() { + fetch('/prompt') + .then(response => response.json()) + .then(data => { + updateStatus(data.exec_info.queue_remaining); + }).catch((response) => {updateStatus(null)}); + } + let ws; function createSocket(isReconnect) { if(ws) return; @@ -501,14 +511,16 @@ document.addEventListener('drop', (event) => { ws.addEventListener("error", () => { if(ws) ws.close(); + manually_fetch_queue(); }); ws.addEventListener("close", () => { setTimeout(() => { ws = null; createSocket(true); - }, 1000); + }, 300); if(opened) { + updateStatus(null); showModal("Reconnecting..."); } });