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: cancel the local song render when its wait times out (#9473)
Adam Eivy07d1d600ec77
diff --git a/server/services/musicVideo/autonomousLocalSong.js b/server/services/musicVideo/autonomousLocalSong.jsindex 77951019cf..16431cbdf7 100644--- a/server/services/musicVideo/autonomousLocalSong.js+++ b/server/services/musicVideo/autonomousLocalSong.js@@ -39,6 +39,7 @@ const defaults = {queueGeneration: async (body) => (await import('../musicGeneration.js')).queueMusicGeneration(body),getJob: async (id) => (await import('../mediaJobQueue/index.js')).getJob(id),getTrack: async (id) => (await import('../tracks/index.js')).getTrack(id),+ cancelJob: async (id) => (await import('../mediaJobQueue/index.js')).cancelJob(id),// Resolves with the job once it reaches a terminal state (the queue's own// events; an already-finished job resolves at once).waitForJob: async (jobId, { timeoutMs }) => {@@ -120,7 +121,11 @@ export async function generateLocalSong({ trackId, title, prompt, lyrics = '', iconsole.log(`🎵 Autonomous music video queued a local song on ${engine.id} (job ${String(jobId).slice(0, 8)})`);}- job = await deps.waitForJob(jobId, { timeoutMs });+ job = await deps.waitForJob(jobId, { timeoutMs }).catch(async (err) => {+ // Give up on the render too, or it keeps the GPU busy behind the next scheduled run.+ if (err.code === 'LOCAL_SONG_TIMEOUT') await deps.cancelJob(jobId).catch(() => {});+ throw err;+ });if (job.status !== 'completed') {throw fail(502, 'LOCAL_SONG_FAILED', `The local song ${job.status === 'canceled' ? 'was canceled' : 'failed to render'}${job.error ? `: ${trimTo(job.error, 300)}` : ''}`, { jobId });}diff --git a/server/services/musicVideo/autonomousLocalSong.test.js b/server/services/musicVideo/autonomousLocalSong.test.jsindex eb7d9a5b13..282fb9a321 100644--- a/server/services/musicVideo/autonomousLocalSong.test.js+++ b/server/services/musicVideo/autonomousLocalSong.test.js@@ -30,6 +30,7 @@ function harness({ healthy = ['musicgen', 'acestep'], tracks = {}, jobs = {}, waqueueGeneration: vi.fn(async () => ({ jobId: 'job-1', status: 'queued' })),getJob: async (id) => state.jobs[id] || null,getTrack: async (id) => state.tracks[id] || null,+ cancelJob: vi.fn(async () => true),// The completion hook attaches the audio a beat after the job reports done.waitForJob: vi.fn(async (id) => waited?.(state, id) ?? { id, status: 'completed', result: { filename: 'song.wav' } }),sleep: vi.fn(async () => { state.tracks['t-1'] = { id: 't-1', audioFilename: 'song.wav' }; }),@@ -135,6 +136,8 @@ describe('the default job waiter', () => {queue.events.emit('canceled', { id: 'job-8', status: 'canceled' });await expect(canceled).rejects.toMatchObject({ code: 'LOCAL_SONG_FAILED' });- await expect(waitWith('job-7', { timeoutMs: 5 })).rejects.toMatchObject({ code: 'LOCAL_SONG_TIMEOUT' });+ const cancelJob = vi.fn(async () => true);+ await expect(waitWith('job-7', { timeoutMs: 5, cancelJob })).rejects.toMatchObject({ code: 'LOCAL_SONG_TIMEOUT' });+ expect(cancelJob).toHaveBeenCalledWith('job-7'); // the abandoned render must not keep the GPU busy});});