Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Keep the queue and a running loop through a short outage, and explain a loop stopped by a long one

Bowen Xuedd1d45253158
diff --git a/web/studio.js b/web/studio.js
index a41b8a6..0e68618 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -1492,7 +1492,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
chain_cancel_failed: t('Could not cancel. Refresh the page and try again.', '没有取消成功,请刷新页面后再试。'),
chain_resume_failed: t('Could not continue. Refresh the page and try again.', '没有继续生成,请刷新页面后再试。'),
}[error?.message] || (error?.said ? t(error.said[0], error.said[1]) : null) || (isNetworkTypeError(error) ? connectionLostText(t) : error?.message) || String(error));
- let lastQueueError = null;
+ let lastQueueError = null, connectionNotice = false;
function showQueueError(error) {
if (disposed) return;
status.dataset.error = 'true';
@@ -1506,11 +1506,21 @@ export function openStudio(node, {extendFrom = null} = {}) {
: queueError(error);
// Recoverable chain actions need one visible sentence, not a second error card.
if (error?.action) { status.scrollIntoView({block: 'nearest'}); return; }
- const identity = error?.schema === 'freevideo.error-report' ? error : error?.message || error;
+ // A loop stopped by a long outage is a new state of the same notice: show its final details once.
+ const identity = error?.schema === 'freevideo.error-report' ? error : error?.loopStopped ? `${error.message} (loop stopped)` : error?.message || error;
if (lastQueueError === identity) return;
lastQueueError = identity;
const report = failure.show(error, error?.schema === 'freevideo.error-report', {stage: 'queue', node, graph: app.graph});
node.freevideoFailureReport = report; node.freevideoFailure = errorText(report);
+ connectionNotice = isNetworkTypeError(error) && !report.browser_extension;
+ }
+ // The queue read works again: take the lost-connection notice down. A failure card for anything else stays.
+ function clearConnectionNotice() {
+ if (!connectionNotice) return;
+ connectionNotice = false;
+ if (node.freevideoFailureReport?.stage !== 'queue') return;
+ lastQueueError = null; failure.clear(); node.freevideoFailure = ''; node.freevideoFailureReport = null;
+ status.dataset.error = 'false'; status.textContent = '';
}
function updateRunButton() {
const submitting = capturing || queueState?.submitting;
@@ -1620,7 +1630,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
}
if (movedId && state.pending.some(row => row.id === movedId) && !queueList.querySelector('.fv-queue-moved')) showMoved();
if (!busy) cancelling = false;
- if (state.error) showQueueError(state.error);
+ if (state.error) showQueueError(state.error); else clearConnectionNotice();
updateRunButton();
}
const syncQueue = () => queueController.refresh();
diff --git a/web/studio_queue.js b/web/studio_queue.js
index e34ddc8..7580237 100644
--- a/web/studio_queue.js
+++ b/web/studio_queue.js
@@ -1,8 +1,13 @@
// ComfyUI owns execution. This controller only submits frozen workflows and
// replenishes a loop after its previous request has actually completed.
-import {fetchQueueRead, detectBrowserExtension} from './browser_extension.js';
+import {fetchQueueRead, detectBrowserExtension, isNetworkTypeError} from './browser_extension.js';
const clone = value => structuredClone(value);
+// One dropped read is usually a connection reset or an engine restart. Only this many
+// polls failing in a row are shown; the next successful read clears the notice.
+// While the outage lasts the polls back off, and a loop is stopped once it passes the limit.
+const OUTAGE_POLLS = 3, OUTAGE_LOOP_LIMIT_MS = 180000, OUTAGE_MAX_DELAY_MS = 8000;
+
// ComfyUI leaves a muted (2) or bypassed (4) node out of the request. The creation panel is where
// the node is used, so a request from it turns the node back on; true when it was off.
export function enableNode(node) {
@@ -123,7 +128,7 @@ export function createStudioQueue(api, nodeId, {random = randomSeed, pollMs = 20
formatError = error => error} = {}) {
nodeId = String(nodeId);
let running = null, pending = [], submitting = false, loop = null, timer = null;
- let refreshing = null, refreshAgain = false, lastError = null, disposed = false;
+ let refreshing = null, refreshAgain = false, lastError = null, disposed = false, outage = null;
const listeners = new Set();
const owned = new Set(), delivered = new Set();
function remember(id) { owned.add(id); if (owned.size > 128) { const old = owned.values().next().value; owned.delete(old); delivered.delete(old); } }
@@ -136,7 +141,8 @@ export function createStudioQueue(api, nodeId, {random = randomSeed, pollMs = 20
const publish = () => { for (const listener of listeners) listener(state()); };
function schedule() {
clearTimeout(timer); timer = null;
- if (!disposed && pollMs && (listeners.size || loop?.active)) timer = setTimeout(() => refresh().catch(() => {}), pollMs);
+ if (!disposed && pollMs && (listeners.size || loop?.active)) timer = setTimeout(() => refresh().catch(() => {}), outage && outage.failures > OUTAGE_POLLS
+ ? Math.min(pollMs * 2 ** (outage.failures - OUTAGE_POLLS), OUTAGE_MAX_DELAY_MS) : pollMs);
}
function fail(error) {
if (loop) loop.active = false;
@@ -218,6 +224,8 @@ export function createStudioQueue(api, nodeId, {random = randomSeed, pollMs = 20
running = (queue.queue_running || []).filter(matches).map(entry)[0] || null;
// Comfy returns its heap array; the queue number gives the real running order.
pending = (queue.queue_pending || []).filter(matches).sort((a, b) => a[0] - b[0]).map(entry);
+ outage = null;
+ if (isNetworkTypeError(lastError) && !lastError.loopStopped) lastError = null;
for (const row of [running, ...pending]) if (row) remember(row.id);
await advanceLoop(); publish();
}
@@ -226,7 +234,21 @@ export function createStudioQueue(api, nodeId, {random = randomSeed, pollMs = 20
if (refreshing) { refreshAgain = true; return refreshing; }
refreshing = (async () => {
do { refreshAgain = false; await readQueue(); } while (refreshAgain && !disposed);
- })().catch(error => { fail(error); throw error; }).finally(() => { refreshing = null; schedule(); });
+ })().catch(error => {
+ if (!isNetworkTypeError(error) || detectBrowserExtension(error)) { fail(error); throw error; }
+ // A lost connection does not stop a loop at first: it only continues after a successful read.
+ outage = {failures: (outage?.failures || 0) + 1, since: outage?.since ?? Date.now()};
+ if (outage.failures < OUTAGE_POLLS) return;
+ // The notice for a stopped loop stays as it is while the outage goes on.
+ if (lastError?.loopStopped) throw error;
+ const lasted = Date.now() - outage.since, giveUp = lasted >= OUTAGE_LOOP_LIMIT_MS && loop?.active;
+ const note = `Queue reads failed ${outage.failures} times in a row over ${Math.round(lasted / 1000)} s; `
+ + `online=${globalThis.navigator?.onLine}, page hidden=${globalThis.document?.hidden}.${giveUp ? ' The loop was stopped.' : ''}`;
+ if (typeof error === 'object' && !String(error.details || '').includes('Queue reads failed')) error.details = [error.details, note].filter(Boolean).join('\n');
+ // A stopped loop keeps its notice after the connection returns, so the user sees why it stopped.
+ if (giveUp) { if (typeof error === 'object') error.loopStopped = true; fail(error); throw error; }
+ lastError = error; publish(); throw error;
+ }).finally(() => { refreshing = null; schedule(); });
return refreshing;
}
async function start(snapshot, {count = 1, repeat = false, seedIndex = -1, onAccepted = null} = {}) {