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: finish the fal.ai job record when its run tail rejects (#8906)

[._.]/ Adam Eivy8e608e45ed69
diff --git a/server/services/fableLoom/falVideoAutomation.js b/server/services/fableLoom/falVideoAutomation.js
index 48273a277c..1e1481d5e1 100644
--- a/server/services/fableLoom/falVideoAutomation.js
+++ b/server/services/fableLoom/falVideoAutomation.js
@@ -503,9 +503,23 @@ export async function startFalVideoAutomation(loomId, episodeId, nodeId, {
// 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.
+ // rejected `runTail` unhandled either. It also finishes the job record
+ // itself: without this, a job that escaped executeJob()'s own failure
+ // handling would stay 'queued'/'running' forever, permanently blocking
+ // this scene from ever starting a new job (see ACTIVE_STATUSES above).
runTail = runTail.then(() => executeJob(job)).catch((error) => {
- console.error(`❌ fal.ai video automation job failed to complete: ${error?.message || error}`);
+ try {
+ console.error(`❌ fal.ai video automation job failed to complete: ${error?.message || error}`);
+ } catch {
+ console.error('❌ fal.ai video automation job failed to complete (error details unreadable)');
+ }
+ if (ACTIVE_STATUSES.has(job.status)) {
+ job.status = 'failed';
+ job.statusMsg = 'fal.ai video failed';
+ job.error = 'fal.ai browser automation failed unexpectedly. Inspect the PortOS Browser tab, then retry.';
+ job.completedAt = new Date().toISOString();
+ emitJob(job);
+ }
});
// Snapshot the queued state before the serialized runner can advance it;
// both same-scene callers receive the same initial API contract.
diff --git a/server/services/fableLoom/falVideoAutomation.test.js b/server/services/fableLoom/falVideoAutomation.test.js
index c74d5561dc..d9c89da333 100644
--- a/server/services/fableLoom/falVideoAutomation.test.js
+++ b/server/services/fableLoom/falVideoAutomation.test.js
@@ -476,8 +476,12 @@ describe('FableLoom fal.ai browser automation', () => {
});
expect(firstJob.status).toBe('queued');
// Let the queue actually attempt (and reject on) the first job before
- // enqueuing the second, so the rejection is in place first.
- await vi.waitFor(() => expect(mocks.getLoom.mock.calls.length).toBeGreaterThanOrEqual(2));
+ // enqueuing the second, so the rejection is in place first. The first
+ // job must itself reach a terminal 'failed' state rather than staying
+ // 'queued'/'running' forever, or it would permanently block this scene
+ // from ever starting a new job (see ACTIVE_STATUSES).
+ const firstResult = await waitForTerminalJob(firstJob);
+ expect(firstResult.status).toBe('failed');
makeBrowser();
const secondJob = await startFalVideoAutomation('loom-1', 'ep-1', 'node-2', {