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: release Sharp file handles in thumbnail tests
[._.]/ Adam Eivy1183a54ffc69
diff --git a/server/lib/fileCore.js b/server/lib/fileCore.jsindex 6efc2e4954..8b74bac9b8 100644--- a/server/lib/fileCore.js+++ b/server/lib/fileCore.js@@ -35,7 +35,7 @@ const isWindows = () => process.platform === 'win32';// to avoid both the writer's destination-missing backup swap and the reader's// phantom "nothing here yet".const WIN_RETRY_ATTEMPTS = 5;-const WIN_RETRY_DELAY_MS = 100;+const WIN_RETRY_DELAY_MS = 10;// rename(2) failures that mean "the destination is momentarily locked", not// "this rename can never work".const WIN_RENAME_LOCK_CODES = ['EPERM', 'EACCES', 'EEXIST', 'EBUSY'];diff --git a/server/lib/imageThumbnail.test.js b/server/lib/imageThumbnail.test.jsindex 9f7e2c5e8f..6898579106 100644--- a/server/lib/imageThumbnail.test.js+++ b/server/lib/imageThumbnail.test.js@@ -8,12 +8,17 @@ const sharpCalls = vi.hoisted(() => ({ count: 0 }));vi.mock('./fileUtils.js', async (original) => makePathsProxy(await original(), { dataRoot: tempRoot }));vi.mock('sharp', async (original) => {const real = (await original()).default;- return { default: (...args) => { sharpCalls.count += 1; return real(...args); } };+ const wrapped = (...args) => { sharpCalls.count += 1; return real(...args); };+ wrapped.cache = (...args) => real.cache(...args);+ return { default: wrapped };});const { default: sharp } = await import('sharp');const { ensureImageThumbnail } = await import('./imageThumbnail.js');-afterAll(() => rmSync(tempRoot, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 }));+afterAll(() => {+ sharp.cache({ files: 0 });+ rmSync(tempRoot, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });+});beforeEach(() => { sharpCalls.count = 0; });async function source(name) {@@ -34,6 +39,9 @@ describe('image thumbnails', () => {const info = await sharp(target).metadata();expect(info.format).toBe('webp');expect(info.width).toBe(683);+ // libvips may keep a metadata-read input file open in its cache. Release it+ // before testing a Windows rewrite of that same derivative.+ sharp.cache({ files: 0 });sharpCalls.count = 0;expect(await ensureImageThumbnail('example.webp')).toBe(true);expect(sharpCalls.count).toBe(0);diff --git a/server/services/assetMounts.test.js b/server/services/assetMounts.test.jsindex b20f8601b2..b9efa26c43 100644--- a/server/services/assetMounts.test.js+++ b/server/services/assetMounts.test.js@@ -28,7 +28,10 @@ const tempRoot = createTempDataRoot('portos-asset-mounts-');vi.mock('../lib/fileUtils.js', async (importOriginal) => (makePathsProxy(await importOriginal(), { dataRoot: tempRoot })));-afterAll(() => rmSync(tempRoot, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 }));+afterAll(() => {+ sharp.cache({ files: 0 });+ rmSync(tempRoot, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });+});// Dynamic, not a static import: the `vi.mock` factory above closes over// `tempRoot`, and a static import would be hoisted above that binding.