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

Clear a finished music-video render's stale error after a restart resume (#11595)

[._.]/fd9b73823065
diff --git a/server/services/musicVideo/render.js b/server/services/musicVideo/render.js
index c8ff932d9a..275ec15ca4 100644
--- a/server/services/musicVideo/render.js
+++ b/server/services/musicVideo/render.js
@@ -98,7 +98,9 @@ export const isLocalRenderMark = (renderingOn, instanceId) => !renderingOn || re
// Every terminal project write clears the in-flight mark's stamp and the
// partial-output pointer alongside the status.
-const settledRender = (status, extra = {}) => ({ status, ...extra, renderingOn: null, renderPartialFilename: null, renderResume: null });
+// A settled render carries no error unless `extra` names one: a finished render
+// never keeps the message of an earlier attempt.
+const settledRender = (status, extra = {}) => ({ status, renderError: null, ...extra, renderingOn: null, renderPartialFilename: null, renderResume: null });
// Tell listeners (the autonomous run waiting on its final render) that a render
// job reached a terminal state. Emitted after the project record's terminal
@@ -1078,7 +1080,7 @@ async function renderFromShotSegments(projectId, project, handOff, options) {
width: plan.width, height: plan.height, numFrames: Math.round(durationSec * plan.fps), fps: plan.fps,
filename, thumbnail: poster, createdAt: new Date().toISOString(), musicVideoProjectId: projectId,
});
- await writeProject(settledRender('complete', { renderHistoryId: jobId, renderDependencies: captureMusicVideoEvidence(project) }), 'complete');
+ await writeProject(settledRender('complete', { renderHistoryId: jobId, renderDependencies: captureMusicVideoEvidence(project)}), 'complete');
return poster;
});
finish('complete');
@@ -1502,6 +1504,11 @@ function scheduleRenderResumes(resumes) {
const { jobId } = await renderMusicVideo(projectId, { resumable: true, resumeAttempt: attempt });
console.log(`🎬 Music Video boot recovery: resumed the final render of ${projectId.slice(0, 8)} [${jobId.slice(0, 8)}] from its cached shots`);
} catch (err) {
+ // Someone started it again in the meantime: that render resumes from the same cache.
+ if (err?.code === 'RENDER_IN_PROGRESS') {
+ console.log(`🎬 Music Video boot recovery: the final render of ${projectId.slice(0, 8)} was already started again`);
+ continue;
+ }
console.error(`❌ Music Video boot recovery: could not resume the final render of ${projectId.slice(0, 8)}: ${err.message}`);
await updateProject(projectId, { renderError: `Interrupted by a server restart and could not restart: ${err.message}`.slice(0, 2000) }).catch(() => {});
}
diff --git a/server/services/musicVideo/render.terminal.test.js b/server/services/musicVideo/render.terminal.test.js
index baa80805ed..1ed51eafc4 100644
--- a/server/services/musicVideo/render.terminal.test.js
+++ b/server/services/musicVideo/render.terminal.test.js
@@ -113,7 +113,7 @@ import { maintenance } from '../../lib/maintenanceAdmission.js';
const tick = () => new Promise((r) => setTimeout(r, 0));
const lastProc = () => h.procs[h.procs.length - 1];
// A terminal project write: the status plus the cleared in-flight mark (#9010).
-const settled = (status, extra = {}) => ({ status, ...extra, renderingOn: null, renderPartialFilename: null, renderResume: null });
+const settled = (status, extra = {}) => ({ status, renderError: null, ...extra, renderingOn: null, renderPartialFilename: null, renderResume: null });
const prime = (projectId) => {
getProject.mockResolvedValue({
@@ -450,6 +450,28 @@ describe('recoverStuckMusicVideoRenders (#8430)', () => {
expect(updateProject).toHaveBeenCalledWith('resume-1', expect.objectContaining({ status: 'rendering', renderResume: { attempt: 1 } }));
logSpy.mockRestore();
});
+
+ it('leaves no error when the render was started again before the resume ran', async () => {
+ const { recoverStuckMusicVideoRenders, renderMusicVideo } = await import('./render.js');
+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
+ vi.useFakeTimers({ toFake: ['setTimeout'] });
+ prime('again-1');
+ getProject.mockResolvedValue({
+ id: 'again-1', name: 'P', trackId: 't1', status: 'ready',
+ scenes: [{ sceneId: 's1', order: 0, videoHistoryId: 'h1' }],
+ composition: { version: 1, mode: 'composed', textCues: [], style: { color: '#ffffff', font: 'sans' }, posterSec: null },
+ });
+ seedStore([{ id: 'again-1', status: 'rendering', renderResume: { attempt: 0 } }]);
+
+ await recoverStuckMusicVideoRenders();
+ await renderMusicVideo('again-1', { resumable: true });
+ await vi.runOnlyPendingTimersAsync();
+ vi.useRealTimers();
+ await tick();
+ expect(seg.plans).toHaveLength(1);
+ expect(updateProject.mock.calls.some(([, patch]) => /could not restart/.test(patch?.renderError || ''))).toBe(false);
+ logSpy.mockRestore();
+ });
});
it('chooses the loudest section midpoint within the rendered duration', async () => {