From 9d37907e729aa589a7cd6c18f447aced3c767d50 Mon Sep 17 00:00:00 2001 From: Michael Wang Date: Fri, 20 Nov 2026 16:30:42 -0800 Subject: [PATCH] fix(media-use): keep a failed write's error when replaceFile can't remove its temp file The preferences store now writes through replaceFile. Its old write made temp cleanup best-effort, so a cleanup error never hid the write error, and the store's tests guard that. replaceFile now does the same. --- packages/cli/src/media-use/lib/manifest.mjs | 8 ++++++-- skills-manifest.json | 2 +- skills/media-use/scripts/lib/manifest.mjs | 8 ++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/media-use/lib/manifest.mjs b/packages/cli/src/media-use/lib/manifest.mjs index 80bcedaef9..9c589289d8 100644 --- a/packages/cli/src/media-use/lib/manifest.mjs +++ b/packages/cli/src/media-use/lib/manifest.mjs @@ -118,8 +118,12 @@ export function replaceFile(path, content) { writeFileSync(temp, content, { flag: "wx" }); renameRidingWindowsHolds(temp, path); } catch (error) { - // EEXIST: the random name belongs to another writer, so it is left alone. - if (error?.code !== "EEXIST") rmSync(temp, { force: true }); + // EEXIST: the random name belongs to another writer, so it is left alone. A failed cleanup must not hide `error`. + if (error?.code !== "EEXIST") { + try { + rmSync(temp, { force: true }); + } catch {} + } throw error; } } diff --git a/skills-manifest.json b/skills-manifest.json index d0c713f70c..0e830cd27f 100644 --- a/skills-manifest.json +++ b/skills-manifest.json @@ -18,7 +18,7 @@ "files": 13 }, "media-use": { - "hash": "78085d6f3c4afd96", + "hash": "9c3e2f0be3c30add", "files": 131 }, "remotion-to-hyperframes": { diff --git a/skills/media-use/scripts/lib/manifest.mjs b/skills/media-use/scripts/lib/manifest.mjs index 80bcedaef9..9c589289d8 100644 --- a/skills/media-use/scripts/lib/manifest.mjs +++ b/skills/media-use/scripts/lib/manifest.mjs @@ -118,8 +118,12 @@ export function replaceFile(path, content) { writeFileSync(temp, content, { flag: "wx" }); renameRidingWindowsHolds(temp, path); } catch (error) { - // EEXIST: the random name belongs to another writer, so it is left alone. - if (error?.code !== "EEXIST") rmSync(temp, { force: true }); + // EEXIST: the random name belongs to another writer, so it is left alone. A failed cleanup must not hide `error`. + if (error?.code !== "EEXIST") { + try { + rmSync(temp, { force: true }); + } catch {} + } throw error; } }