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([issue-1799]): bridge media-job 'failed' to ${kind}-gen:failed so pre-gen queue failures clear stuck render spinners

Adam Eivyc48f9b9aab63
diff --git a/server/services/socket.js b/server/services/socket.js
index 0dc767cd2e..5c6789d567 100644
--- a/server/services/socket.js
+++ b/server/services/socket.js
@@ -1015,4 +1015,20 @@ function setupMediaGenEventForwarding() {
const evt = job.kind === 'video' ? 'video-gen:canceled' : 'image-gen:canceled';
ioInstance.emit(evt, { generationId: job.id });
});
+
+ // Bridge media-job FAILURE onto a `*-gen:failed` socket event keyed by
+ // `generationId` (#1799) — the failure-side analog of the canceled bridge
+ // above. A job that fails *before* the gen run starts (e.g. an unready BYOV
+ // runtime throws synchronously in the queue worker, or the watchdog times the
+ // job out) emits only `mediaJobEvents 'failed'` and never a `*-gen:failed`
+ // frame, so the scene button stays stuck on "Rendering…". Forward it with the
+ // same `{ generationId, error }` shape the gen modules use so the client's
+ // `onFailed` clears the spinner and can toast the reason. For a job that fails
+ // *while running* this fires alongside the gen module's own `failed`; both
+ // settle the spinner to 'failed' and the handler is idempotent.
+ mediaJobEvents.on('failed', (job) => {
+ if (!ioInstance || !job?.id) return;
+ const evt = job.kind === 'video' ? 'video-gen:failed' : 'image-gen:failed';
+ ioInstance.emit(evt, { generationId: job.id, error: job.error });
+ });
}
diff --git a/server/services/socket.test.js b/server/services/socket.test.js
index 2642d6945d..aa32f47a16 100644
--- a/server/services/socket.test.js
+++ b/server/services/socket.test.js
@@ -155,6 +155,21 @@ describe('socket.js — initSocket', () => {
expect(io.emitted).toContainEqual(['video-gen:canceled', { generationId: 'vid-1' }]);
});
+ // ===========================================================================
+ // media-job failure bridge (#1799): mediaJobEvents 'failed' → a
+ // generationId-keyed *-gen:failed broadcast so spinners clear on a queue-level
+ // (pre-gen) failure that never reached the gen module's own failed event.
+ // ===========================================================================
+ it('bridges a failed image job to image-gen:failed keyed by generationId with the error', () => {
+ mediaJobEvents.emit('failed', { id: 'job-fail', kind: 'image', error: 'runtime not ready' });
+ expect(io.emitted).toContainEqual(['image-gen:failed', { generationId: 'job-fail', error: 'runtime not ready' }]);
+ });
+
+ it('bridges a failed video job to video-gen:failed', () => {
+ mediaJobEvents.emit('failed', { id: 'vid-fail', kind: 'video', error: 'BYOV runtime threw' });
+ expect(io.emitted).toContainEqual(['video-gen:failed', { generationId: 'vid-fail', error: 'BYOV runtime threw' }]);
+ });
+
it('two independent sockets can both subscribe to cos independently', () => {
const s1 = makeSocket('s1');
const s2 = makeSocket('s2');