diff --git a/.changeset/vercel-symlink-eexist.md b/.changeset/vercel-symlink-eexist.md new file mode 100644 index 000000000000..133bbc970271 --- /dev/null +++ b/.changeset/vercel-symlink-eexist.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-vercel': patch +--- + +fix: ignore `EEXIST` errors when symlinking traced files that resolve to the same destination diff --git a/packages/adapter-vercel/index.js b/packages/adapter-vercel/index.js index 126f1d2a5090..efe87962e314 100644 --- a/packages/adapter-vercel/index.js +++ b/packages/adapter-vercel/index.js @@ -601,7 +601,13 @@ async function create_function_bundle(builder, entry, dir, config) { if (source !== realpath) { const realdest = path.join(dir, path.relative(ancestor, realpath)); - fs.symlinkSync(path.relative(path.dirname(dest), realdest), dest, is_dir ? 'dir' : 'file'); + try { + fs.symlinkSync(path.relative(path.dirname(dest), realdest), dest, is_dir ? 'dir' : 'file'); + } catch (error) { + // different traced paths can resolve to the same destination + // (e.g. multiple pnpm symlink chains pointing at the same real file) + if (/** @type {NodeJS.ErrnoException} */ (error).code !== 'EEXIST') throw error; + } } else if (!is_dir) { fs.copyFileSync(source, dest); }