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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: skip the idle/completion watchdogs once a manual cancel is tearing down
[._.]/ Adam Eivy1a9bbf991eae
diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.jsindex ab44e60870..8b35f00341 100644--- a/server/services/videoGen/local.js+++ b/server/services/videoGen/local.js@@ -889,7 +889,9 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', m// would crash the Node process, so guard the whole body.try {completionWatchdog = null;- if (activeProcess !== proc || proc.exitCode !== null || proc.signalCode !== null) return;+ // proc.killed covers a manual-cancel SIGTERM that hasn't reached close+ // yet (killWithEscalation sets it before exitCode/signalCode populate).+ if (activeProcess !== proc || proc.killed || proc.exitCode !== null || proc.signalCode !== null) return;console.log(`⚠️ video child reported completion but never exited — SIGKILL [${jobId.slice(0, 8)}]`);completionWatchdogFired = true;proc.kill('SIGKILL');@@ -925,7 +927,13 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', m// can't crash the Node process.try {idleStallTimer = null;- if (activeProcess !== proc || proc.exitCode !== null || proc.signalCode !== null) return;+ // 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 (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');diff --git a/server/services/videoGen/local.test.js b/server/services/videoGen/local.test.jsindex 43a4715788..ddc1ca3e27 100644--- a/server/services/videoGen/local.test.js+++ b/server/services/videoGen/local.test.js@@ -1093,6 +1093,52 @@ describe('generateVideo — pre-output idle-stall deadline', () => {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();