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: drain the media completion-recovery commit in the shutdown flush (#9982)
Adam Eivyb5c0ee094d97
diff --git a/server/services/mediaJobQueue/index.js b/server/services/mediaJobQueue/index.jsindex 2d2dc3df58..cdb19d9d95 100644--- a/server/services/mediaJobQueue/index.js+++ b/server/services/mediaJobQueue/index.js@@ -573,9 +573,11 @@ async function persistImpl() {let completionRecovery = null;function recoverCompletionsUnderAdmission() {if (completionRecovery) return;- completionRecovery = withBackupAssetPublication(() => persist())+ // Tracked as a terminal operation so the shutdown flush drains it (and times+ // out, reporting failure, if an open cut still holds the commit).+ completionRecovery = trackTerminalOperation(withBackupAssetPublication(() => persist()).catch((error) => console.error(`❌ media-job completion recovery commit failed: ${error.message}`))- .finally(() => { completionRecovery = null; });+ .finally(() => { completionRecovery = null; }));}export async function initMediaJobQueue() {@@ -1775,6 +1777,7 @@ export function __resetForTests() {// Un-latch the persistence block (#4115) — a test that booted on an unreadable// jobs file would otherwise leave every later test's queue unable to persist.persistBlocked = false;+ completionRecovery = null;}// Test-only deterministic settle hook. EventEmitter terminal handlers anddiff --git a/server/services/mediaJobQueue/index.test.js b/server/services/mediaJobQueue/index.test.jsindex 68b022cf67..69de78d9e0 100644--- a/server/services/mediaJobQueue/index.test.js+++ b/server/services/mediaJobQueue/index.test.js@@ -3103,4 +3103,18 @@ describe('backup snapshot admission for media completion', () => {files: [`${recovered}.mp4`], queueStatus: 'completed', rows: new Map([[recovered, `${recovered}.mp4`]]),});});+ it('shutdown flush waits on a recovery commit held behind an open cut and reports its failure on timeout', async () => {+ const recovered = await startJob();+ const failures = failTerminalWrites(3);+ renderFinishes(recovered);+ await waitFor(() => failures.count === 3);+ await settle();+ const release = await boundary.acquireBackupSnapshotCut({ timeoutMs: 50 });+ await mediaJobQueue.enqueueJob({ kind: 'video', params: { prompt: 'unrelated' } });+ const flushed = await mediaJobQueue.flushMediaJobQueue({ timeoutMs: 200 });+ expect(flushed).toMatchObject({ ok: false, timedOut: true });+ release();+ await waitFor(() => rows.has(recovered));+ await expect(mediaJobQueue.flushMediaJobQueue()).resolves.toEqual({ ok: true });+ });});