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: cap Suno decoder runtime and fetch after completion evidence
Adam Eivy9ddd7f4b33ab
diff --git a/server/services/musicVideo/autonomousSuno.js b/server/services/musicVideo/autonomousSuno.jsindex 242fe4c25b..abb9137d93 100644--- a/server/services/musicVideo/autonomousSuno.js+++ b/server/services/musicVideo/autonomousSuno.js@@ -201,7 +201,7 @@ async function validateSunoAudio(bytes, { signal, timeoutMs }) {'-nostdin', '-v', 'error', '-xerror', '-err_detect', 'explode','-protocol_whitelist', 'file', '-format_whitelist', 'mp3,wav', '-i', file,'-map', '0:a:0', '-progress', 'pipe:1', '-stats_period', '600', '-f', 'null', '-',- ], safeChildProcessOptions({ signal, timeout: timeoutMs, killSignal: 'SIGKILL', maxBuffer: 64 * 1024 }));+ ], safeChildProcessOptions({ signal, timeout: Math.min(timeoutMs, 15_000), killSignal: 'SIGKILL', maxBuffer: 64 * 1024 }));if (![...stdout.matchAll(/^out_time_us=(\d+)$/gm)].some((match) => Number(match[1]) > 0)) {throw new Error('No decoded audio frames');}@@ -239,6 +239,10 @@ async function downloadSunoAudio(songId, {const candidate = await withAbortTimeout(remaining, async (signal) => {let res;try {+ // Fetch only after observing completion, so a status transition cannot+ // certify bytes downloaded while the song was still rendering.+ const completion = await checkCompletion(songId, { signal });+ signal.throwIfAborted();res = await fetchImpl(sunoAudioUrl(songId), { signal });signal.throwIfAborted();httpStatus = Number.isInteger(res.status) && res.status >= 100 && res.status <= 599 ? res.status : null;@@ -259,8 +263,6 @@ async function downloadSunoAudio(songId, {if (valid !== true) throw new ServerError('Suno: downloaded content is not decodable audio', {status: 502, code: 'SUNO_AUDIO_INVALID', context: { platform: LABEL, reason: 'decode_failed' },});- const completion = await checkCompletion(songId, { signal });- signal.throwIfAborted();if (completion === 'complete') return bytes;if (completion === 'pending') { reason = 'generation_pending'; return null; }throw new ServerError('Suno: audio is decodable, but generation completion is unverified; existing song IDs are retained for retry', {diff --git a/server/services/musicVideo/autonomousSuno.test.js b/server/services/musicVideo/autonomousSuno.test.jsindex a639645fe5..35dd9a5a62 100644--- a/server/services/musicVideo/autonomousSuno.test.js+++ b/server/services/musicVideo/autonomousSuno.test.js@@ -202,6 +202,20 @@ describe('downloadSunoAudio', () => {expect(importAudio).not.toHaveBeenCalled();});+ it('imports bytes fetched after completion rather than certifying an earlier partial body', async () => {+ let checks = 0;+ let complete = false;+ const partial = Buffer.alloc(200 * 1024, 1);+ const finished = Buffer.alloc(200 * 1024, 2);+ const importAudio = vi.fn(async () => ({ filename: 'finished.mp3', sizeBytes: finished.length }));+ await generateSunoSong({}, {+ songIds: [NEW_A], importAudio, validateAudio: completed.validateAudio, sleep: noSleep,+ checkCompletion: async () => { complete = ++checks >= 2; return complete ? 'complete' : 'pending'; },+ fetchImpl: async () => new Response(complete ? finished : partial),+ });+ expect(importAudio).toHaveBeenCalledWith(finished);+ });+it('preserves unknown completion explicitly and never resubmits on retry', async () => {const connect = vi.fn();const importAudio = vi.fn();