Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

ComfyUI: an HTTP error from the isolated worker names that server and its setting

Claude4c2772f8d2d4
diff --git a/src/server/providers/comfyui.ts b/src/server/providers/comfyui.ts
index 6d7e843a..6973d711 100644
--- a/src/server/providers/comfyui.ts
+++ b/src/server/providers/comfyui.ts
@@ -95,14 +95,31 @@ async function comfyFetch(p: string, init: RequestInit = {}, worker: ComfyWorker
}
}
+/**
+ * The isolated worker answered, but not with what was asked (an HTTP error, or a proxy's error page
+ * when the worker behind it is down): say it's that server and where its address is set, so it doesn't
+ * read like the main ComfyUI failed.
+ */
+function isolatedAnswer(what: string, status?: number, detail?: string): ProviderError {
+ const said = status ? `HTTP ${status}` : "something that isn't JSON";
+ return new ProviderError(
+ `The isolated ComfyUI worker at ${baseUrl("isolated")} answered ${said} to ${what}${detail ? ` (${detail})` : ""} — check that it's running (scripts/comfy/README.md) and its address in ${ISOLATED_SETTING}`,
+ status,
+ );
+}
+
+/** A short reason from an error body: its text, unless it's an HTML error page. */
+const reasonOf = (text: string) => (/^\s*</.test(text) ? "" : text.trim().slice(0, 200));
+
/** GET a ComfyUI JSON endpoint. A non-2xx answer or a body that isn't JSON (a proxy's error page) throws, so the runner retries. */
async function comfyJson<T>(p: string, worker: ComfyWorker = "main"): Promise<T> {
const res = await comfyFetch(p, {}, worker);
- if (!res.ok) throw new ProviderError(`ComfyUI ${p.split("?")[0]} answered HTTP ${res.status}`, res.status);
+ const path = p.split("?")[0];
+ if (!res.ok) throw worker === "isolated" ? isolatedAnswer(path, res.status) : new ProviderError(`ComfyUI ${path} answered HTTP ${res.status}`, res.status);
try {
return (await res.json()) as T;
} catch {
- throw new ProviderError(`ComfyUI ${p.split("?")[0]} sent something that isn't JSON (a proxy error page?)`);
+ throw worker === "isolated" ? isolatedAnswer(path) : new ProviderError(`ComfyUI ${path} sent something that isn't JSON (a proxy error page?)`);
}
}
@@ -719,7 +736,10 @@ async function uploadTo(worker: ComfyWorker, data: Buffer, contentType: string,
form.append("type", "input");
form.append("overwrite", "true");
const res = await comfyFetch("/upload/image", { method: "POST", body: form }, worker);
- if (!res.ok) throw new ProviderError(`ComfyUI upload failed: ${res.status} ${await res.text()}`);
+ if (!res.ok) {
+ const text = await res.text().catch(() => "");
+ throw worker === "isolated" ? isolatedAnswer("an upload", res.status, reasonOf(text)) : new ProviderError(`ComfyUI upload failed: ${res.status} ${text}`);
+ }
const j = (await res.json()) as { name: string; subfolder?: string };
const uploaded = j.subfolder ? `${j.subfolder}/${j.name}` : j.name;
// Remember a clip's / track's header facts (length, size, fps, audio) for prepareWorkflow.
@@ -773,6 +793,7 @@ export const comfyProvider: ProviderAdapter = {
const missingPack =
body.error?.type === "missing_node_type" && packs.length ? `This workflow needs the ${packs.join(" + ")} node pack${packs.length > 1 ? "s" : ""} on ${where} (see scripts/comfy/README.md)` : undefined;
const detail = body.node_errors && Object.keys(body.node_errors as object).length ? explainComfyError(body.node_errors, { ...manifest, models: [...manifest.models, ...(input.loras ?? []).map((l) => ({ file: l.file, folder: "loras", url: l.url }))] }) : (missingPack ?? body.error?.message);
+ if (!detail && !res.ok && worker === "isolated") throw isolatedAnswer("the prompt", res.status);
throw new ProviderError(detail ?? `ComfyUI /prompt failed (${res.status})`, res.status);
}
return { externalId: body.prompt_id, meta: { ...meta, ...(worker === "isolated" && { worker }) }, payload: wf };
diff --git a/tests/isolated-worker.test.ts b/tests/isolated-worker.test.ts
index bd87e3cd..e0c62555 100644
--- a/tests/isolated-worker.test.ts
+++ b/tests/isolated-worker.test.ts
@@ -114,6 +114,24 @@ describe("isolated ComfyUI worker", () => {
return comfy(url);
};
await expect(comfyProvider.prepareFile(Buffer.from("video"), "video/mp4", "clip.mp4", route)).rejects.toThrow(/The isolated ComfyUI worker at http:\/\/iso\.test:8189 doesn't answer \(fetch failed\)\. Start it \(scripts\/comfy\/README\.md\) or check Settings → Open-source engine · ComfyUI → Isolated worker URL/);
+ // A proxy in front of a stopped worker answers 502: the message still says which server and where it's set.
+ handler = (url) => {
+ if (url.startsWith("http://iso.test")) return new Response("<html><body><h1>502 Bad Gateway</h1></body></html>", { status: 502, headers: { "Content-Type": "text/html" } });
+ return comfy(url);
+ };
+ const said = /The isolated ComfyUI worker at http:\/\/iso\.test:8189 answered HTTP 502 to (an upload|the prompt|\/history\/iso-1) — check that it's running \(scripts\/comfy\/README\.md\) and its address in Settings → Open-source engine · ComfyUI → Isolated worker URL$/;
+ await expect(comfyProvider.prepareFile(Buffer.from("video"), "video/mp4", "clip.mp4", route)).rejects.toThrow(said);
+ await expect(comfyProvider.submit({ generationId: "g2", model: latent, route, input: { video: "v.mp4", audio: "a.wav" } })).rejects.toThrow(said);
+ await expect(comfyProvider.poll({ externalId: "iso-1", meta: { workflowId: "lipsync-latentsync16", worker: "isolated" }, route, model: latent, createdAt: Date.now() })).rejects.toThrow(said);
+ handler = (url) => (url.startsWith("http://iso.test") ? new Response("upload folder is read-only", { status: 500 }) : comfy(url));
+ await expect(comfyProvider.prepareFile(Buffer.from("video"), "video/mp4", "clip.mp4", route)).rejects.toThrow(/answered HTTP 500 to an upload \(upload folder is read-only\) — check/);
+ // The main server's messages are unchanged.
+ handler = (url) => (url.endsWith("/upload/image") ? new Response("nope", { status: 500 }) : comfy(url));
+ await expect(comfyProvider.prepareFile(Buffer.from("png"), "image/png", "a.png")).rejects.toThrow(/^ComfyUI upload failed: 500 nope$/);
+ handler = (url) => {
+ if (url.startsWith("http://iso.test")) throw new TypeError("fetch failed");
+ return comfy(url);
+ };
// The connection test reports it next to the main server, which still passes.
expect(await comfyProvider.test!()).toEqual({ ok: true, detail: "ComfyUI 0.41.0 · cuda:0 · 24 GB · the isolated worker at http://iso.test:8189 doesn't answer" });
handler = comfy;