Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: allow long-running video renders to finish

[._.]/ Adam Eivyc34a23ea12fa
diff --git a/.env.example b/.env.example
index f21cf7ffe9..c60696a419 100644
--- a/.env.example
+++ b/.env.example
@@ -174,9 +174,6 @@ PGPASSWORD=portos
# Video process grace period after output completion in milliseconds (default: 40000)
# VIDEOGEN_COMPLETION_WATCHDOG_MS=40000
-# Terminate a video render after this many idle milliseconds (default: 600000 / 10 minutes)
-# VIDEOGEN_IDLE_STALL_MS=600000
-
# Terminate an idle queued video job after this many milliseconds (default: 1800000 / 30 minutes)
# MEDIA_JOB_WATCHDOG_VIDEO_MS=1800000
diff --git a/server/services/videoGen/generateVideoHelpers.js b/server/services/videoGen/generateVideoHelpers.js
index 5c5fe01e2d..451544267b 100644
--- a/server/services/videoGen/generateVideoHelpers.js
+++ b/server/services/videoGen/generateVideoHelpers.js
@@ -465,22 +465,14 @@ export function planPromptEncodingRetry({ signal = null, stderr = '', promptEnco
}
/**
- * Whether a PortOS-fired SIGKILL should be treated as success rather than a
- * failure. Two Node-side watchdogs can SIGKILL a render:
- * - the completion watchdog (armed after a completion marker, guards a
- * post-completion teardown hang), and
- * - the pre-output idle-stall deadline (fires when a render goes silent).
- * Either kill is a SUCCESS when a real output file is already on disk and
- * non-empty — e.g. a runtime that wrote its .mp4 but never printed a
- * recognized completion marker (so the completion watchdog never armed) and
- * then hung: the idle timer kills it, but the finished video must still be
- * kept, not discarded as "no output". A kill with no output on disk (a genuine
- * pre-output stall, or a marker from a malformed runtime that wrote nothing)
- * still fails loudly. `idleStallFired` defaults false so existing callers that
- * only track the completion watchdog keep their exact prior behavior.
+ * Whether a PortOS-fired completion-watchdog SIGKILL should be treated as
+ * success rather than a failure. The watchdog is armed after a completion
+ * marker and only guards a post-completion teardown hang. It is a SUCCESS when
+ * a real output file is already on disk and non-empty; a kill with no output on
+ * disk still fails loudly.
*/
-export function isWatchdogSuccess({ completionWatchdogFired, idleStallFired = false, signal, outputPath }) {
- return (completionWatchdogFired || idleStallFired) && signal === 'SIGKILL'
+export function isWatchdogSuccess({ completionWatchdogFired, signal, outputPath }) {
+ return completionWatchdogFired && signal === 'SIGKILL'
&& existsSync(outputPath) && statSync(outputPath).size > 0;
}
diff --git a/server/services/videoGen/local.test.js b/server/services/videoGen/local.test.js
index bebeb18eb1..1bdcedbd41 100644
--- a/server/services/videoGen/local.test.js
+++ b/server/services/videoGen/local.test.js
@@ -2098,7 +2098,7 @@ describe('generateVideo — panel-side completion watchdog', () => {
expect(hang.proc.kill).not.toHaveBeenCalled();
});
- it('never arms the watchdog when no completion marker is seen', async () => {
+ it('allows a render to continue without a completion marker', async () => {
process.env.VIDEOGEN_COMPLETION_WATCHDOG_MS = '40000';
vi.resetModules();
({ generateVideo } = await import('./local.js'));
@@ -2117,346 +2117,14 @@ describe('generateVideo — panel-side completion watchdog', () => {
});
await vi.advanceTimersByTimeAsync(0);
- // Ordinary progress lines must not arm the watchdog.
- hang.emitStdout('STAGE:render:step:5:30:rendering\n');
- hang.emitStdout('60%|██████ | 6/10\n');
+ // A render may be silent for an extended period before it exits. The
+ // completion watchdog is not armed until a completion marker is seen, and
+ // there is no separate idle timeout that can terminate this render.
await vi.advanceTimersByTimeAsync(120000);
expect(hang.proc.kill).not.toHaveBeenCalled();
});
});
-describe('generateVideo — pre-output idle-stall deadline', () => {
- // Same hanging-proc harness as the completion-watchdog suite, but here the
- // render never emits its completion marker — it wedges before (or between)
- // output, which the completion watchdog does NOT cover.
- function makeHangingProc() {
- const listeners = {};
- let stdoutData = null;
- let stderrData = null;
- const proc = {
- pid: 7373,
- exitCode: null,
- signalCode: null,
- killed: false,
- stdout: { on: vi.fn((event, fn) => { if (event === 'data') stdoutData = fn; }) },
- stderr: { on: vi.fn((event, fn) => { if (event === 'data') stderrData = fn; }) },
- on(event, fn) { listeners[event] = fn; return proc; },
- off(event, fn) { if (listeners[event] === fn) delete listeners[event]; return proc; },
- kill: vi.fn((signal) => { proc.killed = true; proc.signalCode = signal; }),
- };
- return {
- proc,
- emitStdout: (text) => stdoutData?.(Buffer.from(text)),
- emitStderr: (text) => stderrData?.(Buffer.from(text)),
- fireClose: (code, signal) => listeners.close?.(code, signal),
- };
- }
-
- beforeEach(() => {
- vi.useFakeTimers();
- });
-
- afterEach(() => {
- vi.useRealTimers();
- delete process.env.VIDEOGEN_IDLE_STALL_MS;
- });
-
- it('SIGKILLs a render that never produces any output within the idle window', async () => {
- process.env.VIDEOGEN_IDLE_STALL_MS = '60000';
- vi.resetModules();
- ({ generateVideo } = await import('./local.js'));
-
- const { spawnDetached } = await import('../../lib/detachedSpawn.js');
- const hang = makeHangingProc();
- vi.mocked(spawnDetached).mockImplementationOnce(async () => hang.proc);
-
- generateVideo({
- jobId: 'idle-stall-no-output',
- pythonPath: '/usr/bin/python3',
- modelId: 'ltx2_unified',
- prompt: 'wedge before any output',
- width: 512, height: 512, numFrames: 25, fps: 24,
- mode: 'text',
- });
- await vi.advanceTimersByTimeAsync(0);
-
- // Just before the deadline: still alive.
- await vi.advanceTimersByTimeAsync(59999);
- expect(hang.proc.kill).not.toHaveBeenCalled();
-
- // Past the deadline with zero output: the idle-stall timer SIGKILLs it.
- await vi.advanceTimersByTimeAsync(2);
- expect(hang.proc.kill).toHaveBeenCalledWith('SIGKILL');
- });
-
- it('resets the idle timer on each output line so a slow-but-alive render is not killed', async () => {
- process.env.VIDEOGEN_IDLE_STALL_MS = '60000';
- vi.resetModules();
- ({ generateVideo } = await import('./local.js'));
-
- const { spawnDetached } = await import('../../lib/detachedSpawn.js');
- const hang = makeHangingProc();
- vi.mocked(spawnDetached).mockImplementationOnce(async () => hang.proc);
-
- generateVideo({
- jobId: 'idle-stall-slow-alive',
- pythonPath: '/usr/bin/python3',
- modelId: 'ltx2_unified',
- prompt: 'slow but steady',
- width: 512, height: 512, numFrames: 25, fps: 24,
- mode: 'text',
- });
- await vi.advanceTimersByTimeAsync(0);
-
- // Emit an output line every 40s (well inside the 60s window) five times —
- // each resets the countdown, so the render is never killed even though the
- // total elapsed time (200s) far exceeds one window.
- for (let i = 0; i < 5; i++) {
- // eslint-disable-next-line no-await-in-loop
- await vi.advanceTimersByTimeAsync(40000);
- hang.emitStdout(`STAGE:render:step:${i}:30:rendering\n`);
- expect(hang.proc.kill).not.toHaveBeenCalled();
- }
- // …but once output stops, the window elapses and it IS killed.
- await vi.advanceTimersByTimeAsync(60001);
- expect(hang.proc.kill).toHaveBeenCalledWith('SIGKILL');
- });
-
- it('counts a stderr line (weight-load/kernel-compile progress) as liveness', async () => {
- process.env.VIDEOGEN_IDLE_STALL_MS = '60000';
- vi.resetModules();
- ({ generateVideo } = await import('./local.js'));
-
- const { spawnDetached } = await import('../../lib/detachedSpawn.js');
- const hang = makeHangingProc();
- vi.mocked(spawnDetached).mockImplementationOnce(async () => hang.proc);
-
- generateVideo({
- jobId: 'idle-stall-stderr-liveness',
- pythonPath: '/usr/bin/python3',
- modelId: 'ltx2_unified',
- prompt: 'stderr keeps it alive',
- width: 512, height: 512, numFrames: 25, fps: 24,
- mode: 'text',
- });
- await vi.advanceTimersByTimeAsync(0);
-
- await vi.advanceTimersByTimeAsync(40000);
- hang.emitStderr('Fetching 12 files: 40%|████ | 5/12\n');
- // The stderr line reset the timer, so 40s later (80s total) it's still alive.
- await vi.advanceTimersByTimeAsync(40000);
- expect(hang.proc.kill).not.toHaveBeenCalled();
- });
-
- it('surfaces a stall-kill as a FAILED job (frees the GPU lane) with a stall-specific reason', async () => {
- process.env.VIDEOGEN_IDLE_STALL_MS = '60000';
- vi.resetModules();
- ({ generateVideo } = await import('./local.js'));
- ({ videoGenEvents } = await import('./events.js'));
-
- // A genuine pre-output stall wrote no real output — a 0-byte (or absent)
- // file. Keep existsSync true (the runtime venv check at build time needs
- // it) but report size 0 so isWatchdogSuccess correctly declines to treat
- // the kill as success; the failure path must report it as a stall.
- const { existsSync, statSync } = await import('fs');
- vi.mocked(existsSync).mockReturnValue(true);
- vi.mocked(statSync).mockReturnValue({ size: 0 });
-
- const { spawnDetached } = await import('../../lib/detachedSpawn.js');
- const hang = makeHangingProc();
- vi.mocked(spawnDetached).mockImplementationOnce(async () => hang.proc);
-
- const events = [];
- const onCompleted = (e) => events.push(['completed', e]);
- const onFailed = (e) => events.push(['failed', e]);
- videoGenEvents.on('completed', onCompleted);
- videoGenEvents.on('failed', onFailed);
-
- generateVideo({
- jobId: 'idle-stall-fails-job',
- pythonPath: '/usr/bin/python3',
- modelId: 'ltx2_unified',
- prompt: 'stall then fail',
- width: 512, height: 512, numFrames: 25, fps: 24,
- mode: 'text',
- });
- await vi.advanceTimersByTimeAsync(0);
-
- // Deadline elapses with no output → SIGKILL.
- await vi.advanceTimersByTimeAsync(60001);
- expect(hang.proc.kill).toHaveBeenCalledWith('SIGKILL');
- // The OS delivers the kill → 'close' fires with signal SIGKILL.
- hang.fireClose(null, 'SIGKILL');
- await vi.advanceTimersByTimeAsync(0);
-
- videoGenEvents.off('completed', onCompleted);
- videoGenEvents.off('failed', onFailed);
-
- const failed = events.find(([k]) => k === 'failed');
- expect(failed).toBeTruthy();
- expect(events.map(([k]) => k)).not.toContain('completed');
- expect(failed[1].error).toMatch(/stalled/i);
- expect(failed[1].error).toMatch(/VIDEOGEN_IDLE_STALL_MS/);
- });
-
- it('treats an idle-stall kill as SUCCESS when a real output file is on disk (runtime wrote its .mp4 but never printed a completion marker, then hung)', async () => {
- process.env.VIDEOGEN_IDLE_STALL_MS = '60000';
- vi.resetModules();
- ({ generateVideo } = await import('./local.js'));
- ({ videoGenEvents } = await import('./events.js'));
-
- // The output file exists + is non-empty — the render finished its real work
- // and wrote the video, but emitted no recognized completion marker, so the
- // completion watchdog never armed and the idle timer is what killed the
- // teardown hang. The finished output must be kept, not discarded.
- const { existsSync, statSync } = await import('fs');
- vi.mocked(existsSync).mockReturnValue(true);
- vi.mocked(statSync).mockReturnValue({ size: 1000 });
-
- const { spawnDetached } = await import('../../lib/detachedSpawn.js');
- const hang = makeHangingProc();
- vi.mocked(spawnDetached).mockImplementationOnce(async () => hang.proc);
-
- const events = [];
- const onCompleted = (e) => events.push(['completed', e]);
- const onFailed = (e) => events.push(['failed', e]);
- videoGenEvents.on('completed', onCompleted);
- videoGenEvents.on('failed', onFailed);
-
- generateVideo({
- jobId: 'idle-stall-output-intact',
- pythonPath: '/usr/bin/python3',
- modelId: 'ltx2_unified',
- prompt: 'wrote output but hung silently',
- width: 512, height: 512, numFrames: 25, fps: 24,
- mode: 'text',
- });
- await vi.advanceTimersByTimeAsync(0);
-
- // No completion marker ever printed; the render goes silent after writing.
- await vi.advanceTimersByTimeAsync(60001);
- expect(hang.proc.kill).toHaveBeenCalledWith('SIGKILL');
- hang.fireClose(null, 'SIGKILL');
- await vi.advanceTimersByTimeAsync(0);
-
- videoGenEvents.off('completed', onCompleted);
- videoGenEvents.off('failed', onFailed);
-
- const kinds = events.map(([k]) => k);
- expect(kinds).toContain('completed');
- expect(kinds).not.toContain('failed');
- });
-
- it('does NOT SIGKILL/finalize when a manual cancel is already tearing the child down (proc.killed race)', async () => {
- process.env.VIDEOGEN_IDLE_STALL_MS = '60000';
- vi.resetModules();
- ({ generateVideo } = await import('./local.js'));
- ({ videoGenEvents } = await import('./events.js'));
-
- // Output file exists + non-empty — so IF the idle timer wrongly fired and
- // set idleStallFired, the close path would misfinalize the canceled render
- // as a SUCCESS. The proc.killed guard must prevent the timer from firing.
- const { existsSync, statSync } = await import('fs');
- vi.mocked(existsSync).mockReturnValue(true);
- vi.mocked(statSync).mockReturnValue({ size: 1000 });
-
- const { spawnDetached } = await import('../../lib/detachedSpawn.js');
- const hang = makeHangingProc();
- vi.mocked(spawnDetached).mockImplementationOnce(async () => hang.proc);
-
- const events = [];
- const onCompleted = (e) => events.push(['completed', e]);
- videoGenEvents.on('completed', onCompleted);
-
- generateVideo({
- jobId: 'idle-stall-cancel-race',
- pythonPath: '/usr/bin/python3',
- modelId: 'ltx2_unified',
- prompt: 'canceled near the idle deadline',
- width: 512, height: 512, numFrames: 25, fps: 24,
- mode: 'text',
- });
- await vi.advanceTimersByTimeAsync(0);
-
- // Simulate cancel(): killWithEscalation SIGTERMs and sets proc.killed
- // before exitCode/signalCode populate (they only settle on close).
- await vi.advanceTimersByTimeAsync(59000);
- hang.proc.killed = true;
- hang.proc.kill.mockClear();
-
- // Deadline elapses — the guard must see proc.killed and bail, NOT SIGKILL.
- await vi.advanceTimersByTimeAsync(2000);
- expect(hang.proc.kill).not.toHaveBeenCalled();
-
- videoGenEvents.off('completed', onCompleted);
- // The idle timer never fired, so nothing finalized this as a success.
- expect(events.map(([k]) => k)).not.toContain('completed');
- });
-
- it('does NOT fire the idle timer when the child exits cleanly (timer cleared on close)', async () => {
- process.env.VIDEOGEN_IDLE_STALL_MS = '60000';
- vi.resetModules();
- ({ generateVideo } = await import('./local.js'));
-
- const { spawnDetached } = await import('../../lib/detachedSpawn.js');
- const hang = makeHangingProc();
- vi.mocked(spawnDetached).mockImplementationOnce(async () => hang.proc);
-
- generateVideo({
- jobId: 'idle-stall-clean-exit',
- pythonPath: '/usr/bin/python3',
- modelId: 'ltx2_unified',
- prompt: 'render and exit',
- width: 512, height: 512, numFrames: 25, fps: 24,
- mode: 'text',
- });
- await vi.advanceTimersByTimeAsync(0);
-
- // Child emits its result and exits cleanly well within the window.
- hang.emitStdout('{"video_path": "/data/videos/out.mp4"}\n');
- hang.proc.exitCode = 0;
- hang.fireClose(0, null);
- await vi.advanceTimersByTimeAsync(0);
-
- // Advancing past the idle window must NOT trigger a SIGKILL — close cleared it.
- await vi.advanceTimersByTimeAsync(120000);
- expect(hang.proc.kill).not.toHaveBeenCalled();
- });
-
- it('falls back to the default window on a missing/invalid VIDEOGEN_IDLE_STALL_MS', async () => {
- // Invalid values must not collapse the guard to 0/NaN (which would kill
- // every render instantly) — they fall back to the generous default.
- for (const bad of ['', '0', '-5', 'lots']) {
- // eslint-disable-next-line no-await-in-loop
- await (async () => {
- if (bad === '') delete process.env.VIDEOGEN_IDLE_STALL_MS;
- else process.env.VIDEOGEN_IDLE_STALL_MS = bad;
- vi.resetModules();
- ({ generateVideo } = await import('./local.js'));
-
- const { spawnDetached } = await import('../../lib/detachedSpawn.js');
- const hang = makeHangingProc();
- vi.mocked(spawnDetached).mockImplementationOnce(async () => hang.proc);
-
- generateVideo({
- jobId: `idle-stall-default-${bad || 'unset'}`,
- pythonPath: '/usr/bin/python3',
- modelId: 'ltx2_unified',
- prompt: 'default window',
- width: 512, height: 512, numFrames: 25, fps: 24,
- mode: 'text',
- });
- await vi.advanceTimersByTimeAsync(0);
- // A minute in — far past 0/NaN but well short of the 10-min default —
- // the render must still be alive.
- await vi.advanceTimersByTimeAsync(60000);
- expect(hang.proc.kill).not.toHaveBeenCalled();
- })();
- }
- delete process.env.VIDEOGEN_IDLE_STALL_MS;
- });
-});
-
describe('generateVideo — video LoRA (--user-loras) arg threading', () => {
it('emits --user-loras JSON with resolved path + strength for ltx2 renders', async () => {
const { spawnDetached } = await import('../../lib/detachedSpawn.js');
@@ -3603,7 +3271,7 @@ describe('generateVideo — signal-death diagnosis (#3101)', () => {
// command-buffer watchdog, which arrives as SIGABRT. Before #3101 every signal
// except SIGKILL fell through to a bare `Killed by signal SIGABRT` with no
// cause and no next step. These assert the close handler's signal→message map
- // AND that the precedence above it (missingPyModule → idleStallFired → signal)
+ // AND that the precedence above it (missingPyModule → signal)
// is preserved.
function makeSignalProc() {
const listeners = {};
diff --git a/server/services/videoGen/spawnWatch.js b/server/services/videoGen/spawnWatch.js
index 8d5b6fc208..d67497f456 100644
--- a/server/services/videoGen/spawnWatch.js
+++ b/server/services/videoGen/spawnWatch.js
@@ -43,11 +43,6 @@ const COMPLETION_WATCHDOG_GRACE_MS = (() => {
return Number.isFinite(raw) && raw > 0 ? raw : 40000;
})();
-const IDLE_STALL_DEADLINE_MS = (() => {
- const raw = parseInt(process.env.VIDEOGEN_IDLE_STALL_MS || '', 10);
- return Number.isFinite(raw) && raw > 0 ? raw : 600000;
-})();
-
const MUXING_DONE_RE = /\[Decoding video \+ audio \+ muxing\]\s+done in/i;
export async function spawnAndWatchVideo({
@@ -140,7 +135,7 @@ export async function spawnAndWatchVideo({
} catch { /* preview is best-effort; the final video remains authoritative */ }
// ── one render child, fully wired ──────────────────────────────────────────
- // Everything per-CHILD lives in here — the process handle, both watchdogs, the
+ // Everything per-CHILD lives in here — the process handle, the completion watchdog, the
// line readers, the close handler — so the same job can be relaunched once
// without minting a new one. Everything job-level (jobId, args, seed, meta,
// history entry, heavy claim, staged temp files) is closed over and survives
@@ -190,55 +185,6 @@ export async function spawnAndWatchVideo({
if (typeof completionWatchdog.unref === 'function') completionWatchdog.unref();
};
- // Pre-output idle-stall deadline. Armed at spawn and reset on every child
- // output line (stdout OR stderr — a render loading weights logs to stderr via
- // loguru/tqdm well before any stdout progress). If it fires, the render has
- // produced NO output for the whole generous window — treat it as wedged,
- // SIGKILL it, and let the 'close' handler surface a failed job so the
- // serialized GPU lane frees. Cleared in every terminal path alongside the
- // completion watchdog so it can't fire against a recycled PID.
- let idleStallTimer = null;
- // Set when THIS timer fires the SIGKILL so the 'close' handler reports a
- // clear "stalled — no output" reason instead of the generic "killed, likely
- // OOM" message a bare SIGKILL would otherwise produce.
- let idleStallFired = false;
- const clearIdleStallTimer = () => {
- if (idleStallTimer) {
- clearTimeout(idleStallTimer);
- idleStallTimer = null;
- }
- };
- const armIdleStallTimer = () => {
- idleStallTimer = setTimeout(() => {
- // Outside the Express request lifecycle — guard so an uncaught throw
- // can't crash the Node process.
- try {
- idleStallTimer = null;
- // Also bail if the child is already being torn down by a manual
- // cancel: killWithEscalation() sends SIGTERM and sets `proc.killed`
- // BEFORE exitCode/signalCode populate on close. Without this check the
- // idle timer could still fire, set idleStallFired, and SIGKILL — and
- // the close handler would then finalize a user-canceled render (whose
- // partial .mp4 is on disk) as a SUCCESS instead of canceled/failed.
- if (videoJobState.activeProcess !== proc || proc.killed || proc.exitCode !== null || proc.signalCode !== null) return;
- console.log(`⚠️ video child produced no output for ${IDLE_STALL_DEADLINE_MS}ms — stalled, SIGKILL [${jobId.slice(0, 8)}]`);
- idleStallFired = true;
- proc.kill('SIGKILL');
- } catch (err) {
- console.error(`❌ idle-stall watchdog failed [${jobId.slice(0, 8)}]: ${err.message}`);
- }
- }, IDLE_STALL_DEADLINE_MS);
- if (typeof idleStallTimer.unref === 'function') idleStallTimer.unref();
- };
- // Every output line means the render is alive — restart the countdown.
- const resetIdleStallTimer = () => {
- clearIdleStallTimer();
- armIdleStallTimer();
- };
- // Arm immediately: the highest-risk stall is a job that never emits its FIRST
- // line (weights load / kernel compile hangs), so the clock starts at spawn.
- armIdleStallTimer();
-
// Hold a sleep-prevention lock for the lifetime of the python child, so a
// 90s+ render doesn't get aborted by sleep on a laptop. `-s` blocks system
// sleep (lid-close / low-power), `-i` blocks idle sleep, `-d` blocks display
@@ -263,7 +209,6 @@ export async function spawnAndWatchVideo({
if (closeHandled) return;
closeHandled = true;
clearCompletionWatchdog();
- clearIdleStallTimer();
job.status = 'error';
const reason = `Failed to spawn ${bin}: ${err.message}`;
console.log(`❌ Video generation spawn error [${jobId.slice(0, 8)}]: ${reason}`);
@@ -335,16 +280,10 @@ export async function spawnAndWatchVideo({
}, { splitRe: /[\n\r]+/ });
proc.stdout.on('data', (chunk) => {
- // Any output proves the render is progressing — restart the idle-stall
- // countdown before parsing so a slow-but-alive render is never killed.
- resetIdleStallTimer();
stdoutReader.push(chunk);
});
proc.stderr.on('data', (chunk) => {
- // Weight-load / kernel-compile progress often streams to stderr (loguru,
- // tqdm) long before the first stdout line — count it as liveness too.
- resetIdleStallTimer();
stderrReader.push(chunk);
});
@@ -359,7 +298,6 @@ export async function spawnAndWatchVideo({
stdoutReader.flush();
stderrReader.flush();
clearCompletionWatchdog();
- clearIdleStallTimer();
// The relaunch window opens the instant the shared active process is cleared: until a
// replacement child is tracked, cancel() has nothing to kill and silently
// reports false. Snapshot the epoch at exactly that boundary so the
@@ -391,14 +329,11 @@ export async function spawnAndWatchVideo({
// uploads, and direct-call audio through the same ownership-aware helper.
await cleanupTempFiles({ includeUploads: true, includeUntrackedAudio: true });
- // A PortOS-fired SIGKILL (completion-teardown watchdog OR idle-stall
- // deadline) is a SUCCESS when the output file is already on disk and
- // non-empty — e.g. a runtime that wrote its .mp4 but never printed a
- // recognized completion marker, then hung: the idle timer kills it, but
- // the finished video must be kept, not discarded as "no output". A kill
- // with no output on disk (a genuine pre-output stall, or a marker from a
- // malformed runtime that wrote nothing) still fails loudly below.
- const watchdogSuccess = isWatchdogSuccess({ completionWatchdogFired, idleStallFired, signal, outputPath });
+ // A PortOS-fired completion-watchdog SIGKILL is a SUCCESS when the
+ // output file is already on disk and non-empty: the render wrote its
+ // result, but the child hung during teardown. A kill with no output on
+ // disk still fails loudly below.
+ const watchdogSuccess = isWatchdogSuccess({ completionWatchdogFired, signal, outputPath });
if (code !== 0 && !watchdogSuccess) {
job.status = 'error';
@@ -414,11 +349,6 @@ export async function spawnAndWatchVideo({
} else {
reason = `Python module '${missingPyModule}' is missing. Install it into the configured Python environment and retry.`;
}
- } else if (idleStallFired) {
- // Distinguish a stall-kill from a real OOM kill — both arrive as
- // SIGKILL, but this one means the render produced NO output for the
- // whole idle window and we terminated it to free the GPU lane.
- reason = `Render stalled — no output for ${Math.round(IDLE_STALL_DEADLINE_MS / 1000)}s; terminated to free the GPU queue (raise VIDEOGEN_IDLE_STALL_MS if this was a legitimately slow render)`;
} else if (signal) {
// Signal → actionable cause (SIGABRT = the macOS Metal command-buffer
// watchdog, SIGBUS/SIGSEGV = a native MLX/Metal crash, SIGKILL = OOM),
@@ -435,8 +365,7 @@ export async function spawnAndWatchVideo({
videoGenEvents.emit('failed', { generationId: jobId, error: reason });
} else {
if (watchdogSuccess) {
- const killCause = idleStallFired ? 'idle-stall deadline' : 'completion teardown hang';
- console.log(`⚠️ video child force-killed (${killCause}) — output is intact [${jobId.slice(0, 8)}]`);
+ console.log(`⚠️ video child force-killed (completion teardown hang) — output is intact [${jobId.slice(0, 8)}]`);
}
await finalizeGeneratedVideo({ job, jobId, outputPath, filename, meta, actualSeed, mutateHistory: mutateVideoHistory });
}