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(media-queue): report persistence failures on stderr (#11519)

[._.]/46b0d555fbe2
diff --git a/server/services/mediaJobQueue/index.js b/server/services/mediaJobQueue/index.js
index 0069859244..7a566056fc 100644
--- a/server/services/mediaJobQueue/index.js
+++ b/server/services/mediaJobQueue/index.js
@@ -877,7 +877,7 @@ function startLaneJob(job, { lane }) {
archive.push(job);
recomputeQueuePositions();
archiveWrite = persist();
- archiveWrite.catch((e) => console.log(`⚠️ mediaJobQueue persist on ${label} done failed: ${e.message}`));
+ archiveWrite.catch((e) => console.error(`❌ media-job [${job.id.slice(0, 8)}] mediaJobQueue persist on ${label} done failed: ${e.message}`));
return archiveWrite;
}
let markRunning;
@@ -1035,7 +1035,7 @@ export function removeArchivedJob(jobId) {
for (const c of sseEntry.clients) c.end();
sseJobs.delete(jobId);
}
- persist().catch((e) => console.log(`⚠️ mediaJobQueue persist on archive prune failed: ${e.message}`));
+ persist().catch((e) => console.error(`❌ media-job [${jobId.slice(0, 8)}] mediaJobQueue persist on archive prune failed: ${e.message}`));
return true;
}
@@ -1224,7 +1224,7 @@ async function runJobLifecycle(job, markDispatched, permit) {
}
if (!progressPersistDirty) return;
progressPersistDirty = false;
- await persist().catch((e) => console.log(`⚠️ mediaJobQueue persist on progress failed: ${e.message}`));
+ await persist().catch((e) => console.error(`❌ media-job [${job.id.slice(0, 8)}] mediaJobQueue persist on progress failed: ${e.message}`));
};
const drainProgressPersist = async () => {
@@ -1381,7 +1381,7 @@ async function runJobLifecycle(job, markDispatched, permit) {
const { remoteInputsDisposable, remoteRecoverySettlement, ...result } = payload;
trackTerminalOperation(
terminate('completed', (j) => { j.result = result; }, remoteInputsDisposable === true)
- .catch((e) => console.log(`⚠️ media-job [${job.id.slice(0, 8)}] terminal handler failed: ${e.message}`)),
+ .catch((e) => console.error(`❌ media-job [${job.id.slice(0, 8)}] terminal handler failed: ${e.message}`)),
);
},
failed: (payload) => {
@@ -1395,7 +1395,7 @@ async function runJobLifecycle(job, markDispatched, permit) {
// is cleaned up still gets a meaningful terminal frame from the
// archived state, rather than the generic "Canceled" fallback.
j.error = 'Canceled while running';
- }, payload.remoteInputsDisposable === true).catch((e) => console.log(`⚠️ media-job [${job.id.slice(0, 8)}] terminal handler failed: ${e.message}`)),
+ }, payload.remoteInputsDisposable === true).catch((e) => console.error(`❌ media-job [${job.id.slice(0, 8)}] terminal handler failed: ${e.message}`)),
);
return;
}
@@ -1404,7 +1404,7 @@ async function runJobLifecycle(job, markDispatched, permit) {
j.error = payload.error || 'unknown error';
videoHolds.captureFailure(j, j.error, payload);
}, payload.remoteInputsDisposable === true)
- .catch((e) => console.log(`⚠️ media-job [${job.id.slice(0, 8)}] terminal handler failed: ${e.message}`)),
+ .catch((e) => console.error(`❌ media-job [${job.id.slice(0, 8)}] terminal handler failed: ${e.message}`)),
);
},
};
diff --git a/server/services/mediaJobQueue/index.test.js b/server/services/mediaJobQueue/index.test.js
index 42fdd198da..34d95350c5 100644
--- a/server/services/mediaJobQueue/index.test.js
+++ b/server/services/mediaJobQueue/index.test.js
@@ -989,6 +989,27 @@ describe('mediaJobQueue', () => {
await waitFor(() => mediaJobQueue.getJob(job.jobId).status === 'completed');
});
+ it('reports a failed debounced progress write to stderr with the job id', async () => {
+ const job = await mediaJobQueue.enqueueJob({ kind: 'video', params: { prompt: 'progress persistence failure' } });
+ await waitFor(() => stubs.generateVideo.mock.calls.length === 1);
+ await waitFor(() => mediaJobQueue.getJob(job.jobId)?.status === 'running');
+ const realWrite = atomicWriteSpy.getMockImplementation();
+ const errorLog = vi.spyOn(console, 'error').mockImplementation(() => {});
+ atomicWriteSpy.mockImplementation(async (path, data) => {
+ if (data?.jobs?.some((entry) => entry.id === job.jobId && entry.progress === 0.25)) throw new Error('synthetic progress disk failure');
+ return realWrite(path, data);
+ });
+ try {
+ videoGenEvents.emit('progress', { generationId: job.jobId, progress: 0.25, message: 'working' });
+ await waitFor(() => errorLog.mock.calls.some(([message]) => String(message).includes('persist on progress failed')));
+ expect(errorLog).toHaveBeenCalledWith(expect.stringContaining(`[${job.jobId.slice(0, 8)}] mediaJobQueue persist on progress failed: synthetic progress disk failure`));
+ expect(mediaJobQueue.getJob(job.jobId)).toMatchObject({ status: 'running', progress: 0.25 });
+ } finally {
+ atomicWriteSpy.mockImplementation(realWrite);
+ errorLog.mockRestore();
+ }
+ });
+
it('refuses a canceled suffix repair at provider dispatch without paying again', async () => {
const { assertPerformanceRepairDispatch } = await import('../musicVideo/revisionService.js');
assertPerformanceRepairDispatch.mockRejectedValueOnce(new Error('This repair revision is canceled'));
@@ -3554,13 +3575,19 @@ describe('backup snapshot admission for media completion', () => {
it('releases admission after a terminal write fails for good, leaving no half-published outcome', async () => {
const failed = await startJob();
const failures = failTerminalWrites(3);
+ const errorLog = vi.spyOn(console, 'error').mockImplementation(() => {});
renderFinishes(failed);
- await waitFor(() => failures.count === 3);
- await settle();
- // The abandoned publication holds nothing: a cut opens at once and sees no half-written outcome.
- const release = await boundary.acquireBackupSnapshotCut({ timeoutMs: 50 });
- expect(capture(failed)).toEqual({ files: [`${failed}.mp4`], queueStatus: 'running', rows: new Map() });
- release();
+ try {
+ await waitFor(() => failures.count === 3);
+ await settle();
+ expect(errorLog).toHaveBeenCalledWith(expect.stringContaining(`media-job [${failed.slice(0, 8)}] terminal handler failed:`));
+ // The abandoned publication holds nothing: a cut opens at once and sees no half-written outcome.
+ const release = await boundary.acquireBackupSnapshotCut({ timeoutMs: 50 });
+ expect(capture(failed)).toEqual({ files: [`${failed}.mp4`], queueStatus: 'running', rows: new Map() });
+ release();
+ } finally {
+ errorLog.mockRestore();
+ }
});
it('recovers an abandoned completion only under admission, never from a write landing mid-cut', async () => {