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: settle a draft excerpt and its revision when render setup fails (#11777)

[._.]/ Adam Eivy4939b0274afa
diff --git a/server/services/musicVideo/excerptRender.js b/server/services/musicVideo/excerptRender.js
index f56f31146a..a749ae4194 100644
--- a/server/services/musicVideo/excerptRender.js
+++ b/server/services/musicVideo/excerptRender.js
@@ -322,22 +322,34 @@ export async function startExcerptRender(projectId, { startSec, endSec, aspect =
const excerptId = excerpt.id;
const jobId = excerptId;
- // Only the cue/card windows overlapping the window are worth capturing —
- // typography outside it never survives the final trim.
- const { cues: plannedCues, style } = projectTypographyPlan(project, clips, probe.sections, probe.totalDuration);
- const allCues = composed ? plannedCues : [];
- const cues = allCues.filter((c) => c.startSec < endClamped && c.endSec > startSec);
- const lyricWindows = (composed ? composedLyricWindows(project, endClamped) : [])
- .filter((w) => w.endSec > startSec).map((w) => ({ ...w, startSec: Math.max(w.startSec, startSec) }));
- const composition = cues.length > 0 || lyricWindows.length > 0 ? project.composition : null;
+ // The record and revision are already marked rendering, so a throw before
+ // the job takes ownership (e.g. the filter-graph temp write) must settle them,
+ // or the revision would refuse to resume until a restart (#11777).
+ let cues; let style; let lyricWindows; let composition; let totalDuration; let graphPath; let plainEncode; let job;
+ try {
+ // Only the cue/card windows overlapping the window are worth capturing —
+ // typography outside it never survives the final trim.
+ const planned = projectTypographyPlan(project, clips, probe.sections, probe.totalDuration);
+ style = planned.style;
+ const allCues = composed ? planned.cues : [];
+ cues = allCues.filter((c) => c.startSec < endClamped && c.endSec > startSec);
+ lyricWindows = (composed ? composedLyricWindows(project, endClamped) : [])
+ .filter((w) => w.endSec > startSec).map((w) => ({ ...w, startSec: Math.max(w.startSec, startSec) }));
+ composition = cues.length > 0 || lyricWindows.length > 0 ? project.composition : null;
- const totalDuration = endClamped - startSec;
- // A long filter graph goes to ffmpeg in this file, removed once ffmpeg exits.
- const graphPath = join(tmpdir(), `portos-music-video-${jobId}.filtergraph`);
- const plainEncode = composition ? null : await filterGraphViaFile(ffmpeg, buildMusicVideoFfmpegArgs(clips, audioPath, outputPath, { audioDurationSec, frameGrid: composed, excerpt: { startSec, endSec: endClamped }, soundBed, grade: composed ? project.composition?.grade : null, beats: project.audioAnalysis?.beats, aspect: canvasAspect }).args, graphPath);
- const job = { id: jobId, projectId, excerptId, status: 'running', clients: [], process: null, totalDuration };
- jobs.set(jobId, job);
- projectExcerptRenders.set(projectId, jobId);
+ totalDuration = endClamped - startSec;
+ // A long filter graph goes to ffmpeg in this file, removed once ffmpeg exits.
+ graphPath = join(tmpdir(), `portos-music-video-${jobId}.filtergraph`);
+ plainEncode = composition ? null : await filterGraphViaFile(ffmpeg, buildMusicVideoFfmpegArgs(clips, audioPath, outputPath, { audioDurationSec, frameGrid: composed, excerpt: { startSec, endSec: endClamped }, soundBed, grade: composed ? project.composition?.grade : null, beats: project.audioAnalysis?.beats, aspect: canvasAspect }).args, graphPath);
+ job = { id: jobId, projectId, excerptId, status: 'running', clients: [], process: null, totalDuration };
+ jobs.set(jobId, job);
+ projectExcerptRenders.set(projectId, jobId);
+ } catch (err) {
+ await settleExcerptRecord(projectId, excerptId, { status: 'error', error: err.message, filename: null, jobId: null }).catch((settleErr) => {
+ console.error(`❌ Music-video excerpt [${jobId.slice(4, 12)}] project ${projectId.slice(0, 8)} could not settle after a setup failure: ${settleErr.message}`);
+ });
+ throw err;
+ }
handedOff = true;
console.log(`🎬 Rendering music-video excerpt [${jobId.slice(4, 12)}]: project=${projectId.slice(0, 8)} range=[${startSec.toFixed(2)},${endClamped.toFixed(2)}]s clips=${clips.length} cues=${cues.length}`);
diff --git a/server/services/musicVideo/excerptRender.test.js b/server/services/musicVideo/excerptRender.test.js
index ec218889cf..bcfbda2e78 100644
--- a/server/services/musicVideo/excerptRender.test.js
+++ b/server/services/musicVideo/excerptRender.test.js
@@ -264,3 +264,22 @@ describe('film look finishing pass on a footage excerpt', () => {
expect(unlink.mock.calls).toEqual([[join('/test/videos', partialFilename)]]);
});
});
+
+describe('excerpt setup failure after the rendering mark (#11777)', () => {
+ it('settles the excerpt, reopens the linked revision, rethrows, and lets the revision render again', async () => {
+ const id = 'excerpt-graph-write-fails';
+ prime(id);
+ h.store.get(id).revisions = [{ id: 'rev-1', status: 'open', sections: [], renderAttempts: 0 }];
+ const failure = new Error('ENOSPC: no space left on device');
+ const spy = vi.spyOn(await import('../../lib/ffmpegFilterGraph.js'), 'filterGraphViaFile').mockRejectedValueOnce(failure);
+ await expect(startExcerptRender(id, { startSec: 0, endSec: 2 }, { revisionId: 'rev-1' })).rejects.toBe(failure);
+ const [record] = h.store.get(id).excerpts;
+ expect(record.status).toBe('error');
+ expect(record.error).toBe(failure.message);
+ expect(h.store.get(id).revisions[0].status).toBe('open');
+ spy.mockRestore();
+ const retry = await startExcerptRender(id, { startSec: 0, endSec: 2 }, { revisionId: 'rev-1' });
+ expect(retry.jobId).toBeTruthy();
+ expect(h.store.get(id).revisions[0].status).toBe('rendering');
+ });
+});