Skip to content

Commit 1cdacf0

Browse files
committed
Patch Astro fs.rename to fix EXDEV error in Docker builds
1 parent e3b6ae7 commit 1cdacf0

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

astro/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"url": "https://github.com/DuendeSoftware/docs.duendesoftware.com.git"
1313
},
1414
"notes": {
15-
"Astro SVG validation issue": "https://github.com/withastro/astro/issues/13006"
15+
"Astro SVG validation issue": "https://github.com/withastro/astro/issues/13006",
16+
"Astro EXDEV rename issue": "fs.rename fails across Docker mount boundaries (cross-device); patched to fall back to copy+unlink"
1617
},
1718
"scripts": {
1819
"dev": "astro dev",

astro/patches/astro+6.1.4.patch

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,25 @@ index 0f22881..41cd9ef 100644
1111
calculate(input) {
1212
const root = extractorRegExps.root.exec(toUTF8String(input));
1313
if (root) {
14+
diff --git a/node_modules/astro/dist/core/build/static-build.js b/node_modules/astro/dist/core/build/static-build.js
15+
index 79f476a..afb77e9 100644
16+
--- a/node_modules/astro/dist/core/build/static-build.js
17+
+++ b/node_modules/astro/dist/core/build/static-build.js
18+
@@ -384,7 +384,7 @@ async function ssrMoveAssets(opts, internals, prerenderOutputDir) {
19+
if (!fs.existsSync(currentUrl)) return;
20+
const dir = new URL(path.parse(clientUrl.href).dir);
21+
if (!fs.existsSync(dir)) await fs.promises.mkdir(dir, { recursive: true });
22+
- return fs.promises.rename(currentUrl, clientUrl);
23+
+ try { return await fs.promises.rename(currentUrl, clientUrl); } catch (e) { if (e.code === 'EXDEV') { await fs.promises.copyFile(currentUrl, clientUrl); await fs.promises.unlink(currentUrl); } else { throw e; } }
24+
})
25+
);
26+
}
27+
@@ -400,7 +400,7 @@ async function ssrMoveAssets(opts, internals, prerenderOutputDir) {
28+
if (!fs.existsSync(currentUrl)) return;
29+
const dir = new URL(path.parse(clientUrl.href).dir);
30+
if (!fs.existsSync(dir)) await fs.promises.mkdir(dir, { recursive: true });
31+
- return fs.promises.rename(currentUrl, clientUrl);
32+
+ try { return await fs.promises.rename(currentUrl, clientUrl); } catch (e) { if (e.code === 'EXDEV') { await fs.promises.copyFile(currentUrl, clientUrl); await fs.promises.unlink(currentUrl); } else { throw e; } }
33+
})
34+
);
35+
removeEmptyDirs(fileURLToPath(serverRoot));

0 commit comments

Comments
 (0)