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: keep invalid FableLoom media from stalling exports (#13107)

Adam Eivy55f01e9024e1
diff --git a/server/services/fableLoom/exportMedia.js b/server/services/fableLoom/exportMedia.js
index 2e65b869c3..4d538a4ebc 100644
--- a/server/services/fableLoom/exportMedia.js
+++ b/server/services/fableLoom/exportMedia.js
@@ -22,7 +22,7 @@ export async function readFableLoomExportSource(root, filename) {
const base = await realpath(root);
const path = await realpath(join(base, filename));
if (!isPathInsideDir(base, path)) throw refusal('EXPORT_MEDIA_PATH', 'Media resolves outside its approved root.');
- const handle = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW || 0));
+ const handle = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW || 0) | (constants.O_NONBLOCK || 0));
try {
const before = await handle.stat();
if (!before.isFile() || before.size <= 0 || before.size > FABLELOOM_EXPORT_LIMITS.maxAssetBytes) {
diff --git a/server/services/fableLoom/exports.test.js b/server/services/fableLoom/exports.test.js
index bc1f5e4c13..d267ce72b2 100644
--- a/server/services/fableLoom/exports.test.js
+++ b/server/services/fableLoom/exports.test.js
@@ -1,5 +1,6 @@
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it as vitestIt, vi } from 'vitest';
import { createHash } from 'node:crypto';
+import { closeSync, constants, openSync } from 'node:fs';
import { mkdir, readFile, rm, stat, symlink, truncate, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import express from 'express';
@@ -10,6 +11,7 @@ import { errorMiddleware } from '../../lib/errorHandler.js';
import { readZipArchive } from '../../lib/zipArchive.js';
import { findFfmpeg, findFfprobe, runFfmpegProcess } from '../../lib/ffmpeg.js';
import { FABLELOOM_EXPORT_LIMITS } from '../../lib/fableLoomExport.js';
+import { execFileSync } from '../../lib/childProcess.js';
vi.mock('../../lib/paths.js', async original => makePathsProxy(await original(), {
dataRoot: () => lazyTempDataRoot('portos-fableloom-export-'),
@@ -36,6 +38,7 @@ const bin = await findFfmpeg();
const probe = await findFfprobe();
const canPrepareVideo = Boolean(bin && probe);
const videoIt = canPrepareVideo ? it : vitestIt.skip;
+const posixIt = process.platform === 'win32' ? vitestIt.skip : it;
const privateMarker = 'EXAMPLE_PRIVATE_SENTINEL';
const sourcePath = '/example-private/source';
let sourceImage;
@@ -334,4 +337,27 @@ describe('portable FableLoom export boundary', () => {
.toThrow(expect.objectContaining({ code: 'EXPORT_PACKAGE_SIZE' }));
expect(store.byteLength).toBe(3);
});
+
+ posixIt('rejects a named pipe without a writer and lets the next queued export progress', async ({ signal }) => {
+ const pipe = join(PATHS.images, 'pipe.png');
+ execFileSync('mkfifo', [pipe], { timeout: 5000 });
+ const releaseBlockedReader = () => {
+ try { closeSync(openSync(pipe, constants.O_WRONLY | constants.O_NONBLOCK)); }
+ catch (failure) { if (!['ENXIO', 'ENOENT'].includes(failure.code)) throw failure; }
+ };
+ signal.addEventListener('abort', releaseBlockedReader, { once: true });
+ try {
+ loom.episodes[0].nodes[0].image = 'pipe.png';
+ const result = await terminal(await begin({ episodeIds: ['episode-one'] }));
+ expect(result).toMatchObject({ status: 'failed', error: { code: 'EXPORT_MEDIA_SIZE' } });
+ loom.episodes[0].nodes[0].image = null;
+ const next = await terminal(await begin({ episodeIds: ['episode-one'] }));
+ expect(next).toMatchObject({ status: 'failed', error: { code: 'EXPORT_VALIDATION_FAILED' } });
+ } finally {
+ releaseBlockedReader();
+ signal.removeEventListener('abort', releaseBlockedReader);
+ await __testing.drain();
+ await rm(pipe);
+ }
+ });
});