Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(create): a ComfyUI that dies on startup says why, not 'did not come up'

purple0cb42a8c2b45
diff --git a/src-tauri/src/commands/process.rs b/src-tauri/src/commands/process.rs
index b36815b0..139cbbe2 100644
--- a/src-tauri/src/commands/process.rs
+++ b/src-tauri/src/commands/process.rs
@@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
-use std::sync::Mutex;
+use std::sync::{Arc, Mutex};
use tauri::{Manager, State};
use tracing::{error, info};
@@ -1291,27 +1291,42 @@ fn start_comfyui_blocking(state: &AppState) -> Result<serde_json::Value, String>
#[cfg(target_os = "windows")]
assign_to_kill_on_close_job(&child);
- // Drain stdout/stderr in background threads to prevent buffer deadlock
+ // Drain stdout/stderr in background threads to prevent buffer deadlock.
+ // Each line also lands in the comfy_output ring buffer (GH #98): the
+ // shipped app has no console, so a startup crash printed here was
+ // invisible and every "did not come up" report ended in a blind spot.
+ {
+ let mut buf = state.comfy_output.lock().unwrap();
+ buf.clear();
+ buf.push_back(format!("[start] {} main.py --port {}", python, port_str));
+ }
+ let capture = |line: String, sink: &Arc<Mutex<std::collections::VecDeque<String>>>| {
+ println!("[ComfyUI] {}", line);
+ if let Ok(mut buf) = sink.lock() {
+ if buf.len() >= 400 {
+ buf.pop_front();
+ }
+ buf.push_back(line);
+ }
+ };
if let Some(stdout) = child.stdout.take() {
+ let sink = state.comfy_output.clone();
std::thread::spawn(move || {
use std::io::{BufRead, BufReader};
let reader = BufReader::new(stdout);
- for line in reader.lines() {
- if let Ok(line) = line {
- println!("[ComfyUI] {}", line);
- }
+ for line in reader.lines().map_while(Result::ok) {
+ capture(line, &sink);
}
});
}
if let Some(stderr) = child.stderr.take() {
+ let sink = state.comfy_output.clone();
std::thread::spawn(move || {
use std::io::{BufRead, BufReader};
let reader = BufReader::new(stderr);
- for line in reader.lines() {
- if let Ok(line) = line {
- println!("[ComfyUI] {}", line);
- }
+ for line in reader.lines().map_while(Result::ok) {
+ capture(line, &sink);
}
});
}
@@ -1366,6 +1381,27 @@ fn stop_comfyui_blocking(state: &AppState) -> Result<serde_json::Value, String>
}
}
+/// The last lines ComfyUI printed (GH #98). This is what "Check Settings →
+/// AI Backends" could never show: the actual crash. Also reports whether the
+/// tracked child has exited, so the frontend can say "crashed" instead of
+/// "still starting" while it polls a port that will never open.
+#[tauri::command]
+pub fn comfyui_last_output(state: State<'_, AppState>) -> Result<serde_json::Value, String> {
+ let lines: Vec<String> = state
+ .comfy_output
+ .lock()
+ .map(|b| b.iter().cloned().collect())
+ .unwrap_or_default();
+ let exited = {
+ let mut proc = state.comfy_process.lock().unwrap();
+ match proc.as_mut() {
+ Some(child) => matches!(child.try_wait(), Ok(Some(_)) | Err(_)),
+ None => true,
+ }
+ };
+ Ok(serde_json::json!({ "lines": lines, "exited": exited }))
+}
+
#[tauri::command]
pub async fn comfyui_status(state: State<'_, AppState>) -> Result<serde_json::Value, String> {
let port = *state.comfy_port.lock().unwrap();
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 867de2e1..48efc2c6 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -107,6 +107,7 @@ fn main() {
commands::process::stop_comfyui,
commands::process::fix_comfyui_cors,
commands::process::comfyui_status,
+ commands::process::comfyui_last_output,
commands::process::find_comfyui,
commands::process::detect_all_comfyui_installs,
commands::process::set_comfyui_path,
diff --git a/src-tauri/src/state.rs b/src-tauri/src/state.rs
index 0e55c6d9..264019e5 100644
--- a/src-tauri/src/state.rs
+++ b/src-tauri/src/state.rs
@@ -268,6 +268,12 @@ pub struct AppState {
/// ran on the CPU). None = LU hasn't started ComfyUI this session.
/// Surfaced to the Create tab via `get_comfy_gpu_status`.
pub comfy_started_cpu: Mutex<Option<bool>>,
+ /// Ring buffer of the last ComfyUI stdout/stderr lines (GH #98). The
+ /// shipped app has no console, so a main.py that crashes on startup was
+ /// invisible: the user saw "did not come up" with nothing to check.
+ /// The drain threads push here; `comfyui_last_output` reads it back.
+ /// Arc because the drain threads outlive the command's State borrow.
+ pub comfy_output: Arc<Mutex<std::collections::VecDeque<String>>>,
// ── In-process MLX media engine (macOS Apple-Silicon local image/video) ──
// Ported from uselu/apps/bridge's `commands::mlx` / `commands::video`. The
// app spawns its OWN Python MLX sidecar (server.py on 127.0.0.1:47712) —
@@ -360,6 +366,7 @@ impl AppState {
comfy_gpu_cache: Mutex::new(HashMap::new()),
comfy_gpu_mode: Mutex::new("auto".to_string()),
comfy_started_cpu: Mutex::new(None),
+ comfy_output: Arc::new(Mutex::new(std::collections::VecDeque::new())),
install_mlx_diffusion: crate::install_state::InstallSlot::default(),
install_mlx_image_model: crate::install_state::InstallSlot::default(),
install_mlx_video: crate::install_state::InstallSlot::default(),
diff --git a/src/api/backend.ts b/src/api/backend.ts
index 9322c6db..ba2a7470 100644
--- a/src/api/backend.ts
+++ b/src/api/backend.ts
@@ -413,6 +413,7 @@ export async function backendCall<T = any>(
start_comfyui: { path: "/local-api/start-comfyui", method: "POST" },
stop_comfyui: { path: "/local-api/stop-comfyui", method: "POST" },
comfyui_status: { path: "/local-api/comfyui-status" },
+ comfyui_last_output: { path: "/local-api/comfyui-last-output" },
find_comfyui: { path: "/local-api/find-comfyui" },
set_comfyui_path: { path: "/local-api/set-comfyui-path", method: "POST" },
install_comfyui: { path: "/local-api/install-comfyui", method: "POST" },
diff --git a/src/components/create/experimental/CreateContext.tsx b/src/components/create/experimental/CreateContext.tsx
index b5db2f4f..babe3166 100644
--- a/src/components/create/experimental/CreateContext.tsx
+++ b/src/components/create/experimental/CreateContext.tsx
@@ -11,6 +11,7 @@ import { installMlxStack } from '../../../api/mlx-install'
import { useDownloadStore } from '../../../stores/downloadStore'
import { downloadBundleFiles, waitOrAbort } from '../../../lib/bundle-install'
import { ensureLocalFilename } from './loadImage'
+import { comfyStartupError } from './comfyError'
import type { CloudQuota } from '../../../lib/render/cloud-jobs'
/** Restart ComfyUI so a freshly installed node pack registers (packs only load
@@ -229,8 +230,15 @@ export function CreateExpProvider({ children }: { children: ReactNode }) {
onProgress?.(`Starting ComfyUI… ${i * 2}s`)
await waitOrAbort(2000, signal)
if (await checkComfyConnection()) { checkConnection(); return }
+ // The process died — every further poll waits on a port that will
+ // never open. Fail now, with the crash instead of a guess (GH #98:
+ // the shipped app has no console, so "did not come up" was a dead
+ // end with nothing behind it).
+ const out = await backendCall<{ lines?: string[]; exited?: boolean }>('comfyui_last_output').catch(() => null)
+ if (out?.exited) throw new Error(comfyStartupError(out.lines))
}
- throw new Error('Installed ComfyUI but it did not come up. Check Settings → AI Backends.')
+ const out = await backendCall<{ lines?: string[] }>('comfyui_last_output').catch(() => null)
+ throw new Error(comfyStartupError(out?.lines))
}, [checkConnection])
// Install a capability in place — mirrors the VHS one-click flow (#72):
diff --git a/src/components/create/experimental/__tests__/comfy-startup-error.test.ts b/src/components/create/experimental/__tests__/comfy-startup-error.test.ts
new file mode 100644
index 00000000..0cde580e
--- /dev/null
+++ b/src/components/create/experimental/__tests__/comfy-startup-error.test.ts
@@ -0,0 +1,31 @@
+import { describe, it, expect } from 'vitest'
+import { comfyStartupError } from '../comfyError'
+
+// GH #98: "did not come up" used to be a dead end. The error must carry the
+// crash tail when there is one, and stay the old pointer when there is not.
+describe('comfyStartupError', () => {
+ it('falls back to the settings pointer without output', () => {
+ expect(comfyStartupError()).toContain('Check Settings')
+ expect(comfyStartupError([])).toContain('Check Settings')
+ expect(comfyStartupError([' ', ''])).toContain('Check Settings')
+ })
+
+ it('carries the last meaningful lines of a crash', () => {
+ const lines = [
+ '[start] python main.py --port 8188',
+ 'Traceback (most recent call last):',
+ ' File "main.py", line 1, in <module>',
+ "ModuleNotFoundError: No module named 'torch'",
+ ]
+ const msg = comfyStartupError(lines)
+ expect(msg).toContain('did not come up')
+ expect(msg).toContain("ModuleNotFoundError: No module named 'torch'")
+ })
+
+ it('keeps only the tail of a long log', () => {
+ const lines = Array.from({ length: 50 }, (_, i) => `line ${i}`)
+ const msg = comfyStartupError(lines)
+ expect(msg).toContain('line 49')
+ expect(msg).not.toContain('line 40\n')
+ })
+})
diff --git a/src/components/create/experimental/comfyError.ts b/src/components/create/experimental/comfyError.ts
new file mode 100644
index 00000000..5a0a1167
--- /dev/null
+++ b/src/components/create/experimental/comfyError.ts
@@ -0,0 +1,9 @@
+/** Turn the ComfyUI output tail into an error a person can act on. The last
+ * lines of a startup crash name the real problem (a torch import error, a
+ * missing DLL, an OOM); without them the message was a dead end (GH #98). */
+export function comfyStartupError(lines?: string[]): string {
+ const tail = (lines ?? []).map((l) => l.trim()).filter(Boolean).slice(-6)
+ const base = 'Installed ComfyUI but it did not come up.'
+ if (!tail.length) return `${base} Check Settings → AI Backends.`
+ return `${base} Its last output:\n${tail.join('\n')}`
+}