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: honor video cancellation before provider dispatch (#9036)
[._.]/ Adam Eivy9fc9dcb89754
diff --git a/server/services/mediaJobQueue/index.js b/server/services/mediaJobQueue/index.jsindex 686633f987..870055bb06 100644--- a/server/services/mediaJobQueue/index.js+++ b/server/services/mediaJobQueue/index.js@@ -1249,6 +1249,13 @@ async function runJob(job) {cancelRequested: job.params?.remoteMedia?.cancelRequested === true,};}+ // Remote recovery must still reach its adapter to cancel an existing render.+ // Local cancellation before dispatch owns no provider process to stop.+ if (job.cancelRequested && !isRemoteMediaJob(job)) {+ throw new Error('Canceled before provider dispatch');+ }+ // Transient, like terminating: no await between this flag and invocation.+ job.providerInvoked = true;if (job.kind === 'video' && safeParams.chunks > 1) {await mod.generateChainedVideo({ ...safeParams, jobId: job.id });} else if (job.kind === 'video') {@@ -1486,7 +1493,8 @@ export async function cancelJob(jobId) {// cancellation rather than silently resurrecting the remote render.await persist().catch((e) => console.log(`⚠️ mediaJobQueue persist on remote cancel failed: ${e.message}`));}- if (mod?.cancel && mod.cancel(jobId) === false) {+ if (mod?.cancel && mod.cancel(jobId) === false+ && (runningJob.providerInvoked || isRemoteMediaJob(runningJob))) {// A provider may have crossed its durable finalization boundary before// its completed event reaches the queue. Refusal must not turn a later// finalization failure into a cancellation or leave retry markers set.diff --git a/server/services/mediaJobQueue/index.test.js b/server/services/mediaJobQueue/index.test.jsindex 4963dc81d4..acdd4c4fc1 100644--- a/server/services/mediaJobQueue/index.test.js+++ b/server/services/mediaJobQueue/index.test.js@@ -786,6 +786,40 @@ describe('mediaJobQueue', () => {await waitFor(() => mediaJobQueue.getJob(job.jobId).status === 'completed');});+ it('cancels during dispatch validation without invoking the provider and cleans staged uploads', async () => {+ const { assertVideoAttemptDispatch } = await import('../creativeDirector/videoExecution.js');+ let releaseDispatch;+ let enteredDispatch;+ const entered = new Promise((resolve) => { enteredDispatch = resolve; });+ const gate = new Promise((resolve) => { releaseDispatch = resolve; });+ assertVideoAttemptDispatch.mockImplementationOnce(() => {+ enteredDispatch();+ return gate;+ });+ const uploads = join(tempDataDir, 'uploads');+ mkdirSync(uploads, { recursive: true });+ const uploadedTempPath = join(uploads, 'example-frame.png');+ const audioFilePath = join(uploads, 'example-audio.wav');+ const extraPath = join(uploads, 'example-extra.png');+ for (const path of [uploadedTempPath, audioFilePath, extraPath]) writeFileSync(path, 'staged');+ const job = await mediaJobQueue.enqueueJob({ kind: 'video', params: {+ prompt: 'cancel before dispatch', uploadedTempPath, audioFilePath,+ uploadedTempPaths: [extraPath],+ videoProduction: { projectId: 'example-project', attemptId: 'example-attempt' },+ } });+ await entered;+ stubs.cancelVideo.mockReturnValueOnce(false);+ try {+ await expect(mediaJobQueue.cancelJob(job.jobId)).resolves.toEqual({ ok: true, status: 'canceling' });+ } finally {+ releaseDispatch();+ }+ await waitFor(() => mediaJobQueue.getJob(job.jobId).status === 'canceled');+ expect(stubs.generateVideo).not.toHaveBeenCalled();+ expect(stubs.generateChainedVideo).not.toHaveBeenCalled();+ for (const path of [uploadedTempPath, audioFilePath, extraPath]) expect(existsSync(path)).toBe(false);+ });+it('restores cancellation bookkeeping when a provider refuses during finalization', async () => {const job = await mediaJobQueue.enqueueJob({ kind: 'video', params: {mode: 'grok', prompt: 'finishing render', videoProduction: { submissionUncertain: false },