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: attach the fal.ai queue's rejection recovery immediately (#8906)
[._.]/ Adam Eivy3532421f150e
diff --git a/server/services/fableLoom/falVideoAutomation.js b/server/services/fableLoom/falVideoAutomation.jsindex b137ff577d..48273a277c 100644--- a/server/services/fableLoom/falVideoAutomation.js+++ b/server/services/fableLoom/falVideoAutomation.js@@ -498,13 +498,15 @@ export async function startFalVideoAutomation(loomId, episodeId, nodeId, {// every user-requested scene job, but serialize them so a later click// cannot replace the prompt/image of an in-flight render.// executeJob() catches and records its own failures on the job object, but- // a rare failure before that internal catch (e.g. teardown throwing in the- // finally block) would otherwise leave `runTail` permanently rejected,- // silently skipping every future job's executeJob() call. Recover here so- // one failed run never wedges the queue for subsequent jobs.- runTail = runTail.catch((error) => {- console.error(`❌ fal.ai video automation queue recovered from a prior failure: ${error?.message || error}`);- }).then(() => executeJob(job));+ // a rare failure before that internal catch (e.g. its own diagnostic+ // formatting throwing) would otherwise leave the stored `runTail` rejected,+ // silently skipping every future job's executeJob() call. The recovery+ // catch is attached in the same expression that starts the job — not+ // deferred until the next job is queued — so an idle queue never leaves a+ // rejected `runTail` unhandled either.+ runTail = runTail.then(() => executeJob(job)).catch((error) => {+ console.error(`❌ fal.ai video automation job failed to complete: ${error?.message || error}`);+ });// Snapshot the queued state before the serialized runner can advance it;// both same-scene callers receive the same initial API contract.return publicJob(job);diff --git a/server/services/fableLoom/falVideoAutomation.test.js b/server/services/fableLoom/falVideoAutomation.test.jsindex 91ab791521..c74d5561dc 100644--- a/server/services/fableLoom/falVideoAutomation.test.js+++ b/server/services/fableLoom/falVideoAutomation.test.js@@ -487,4 +487,32 @@ describe('FableLoom fal.ai browser automation', () => {const settled = await waitForTerminalJob(secondJob);expect(settled.status).toBe('completed');});++ it('does not leave an unhandled rejection on the run tail while the queue sits idle', async () => {+ // Same failure shape as above, but with no follow-up job ever enqueued —+ // the recovery catch must be attached to `runTail` immediately when the+ // job starts, not deferred until a later job arrives to chain onto it.+ class UnreadableNameError extends Error {+ get name() { throw new Error('name accessor blew up'); }+ }+ const unhandled = vi.fn();+ process.on('unhandledRejection', unhandled);+ try {+ mocks.getLoom+ .mockResolvedValueOnce(loomWithImage())+ .mockRejectedValueOnce(new UnreadableNameError('scene check failed'));++ await startFalVideoAutomation('loom-1', 'ep-1', 'node-1', {+ prompt: 'Example direction', io: null,+ });+ // Give the queued job's promise chain a full turn to settle (and, if+ // unfixed, to surface as an unhandled rejection) with no other job+ // ever queued afterward.+ await vi.waitFor(() => expect(mocks.getLoom.mock.calls.length).toBeGreaterThanOrEqual(2));+ await new Promise((resolve) => { setImmediate(resolve); });+ } finally {+ process.off('unhandledRejection', unhandled);+ }+ expect(unhandled).not.toHaveBeenCalled();+ });});