Skip to content

Commit

Permalink
ignore EEXIST errors when creating symlinks for output standalone (ve…
Browse files Browse the repository at this point in the history
…rcel#40150)

I think the `EEXIST` error may be because next already copies some files here
https://github.com/vercel/next.js/blob/e91cbcc03d7226cc6f2edb66c656ae08bdf5b903/packages/next/build/index.ts#L2442


partially fixes vercel#36386 when using pnpm linker

## Bug

- [x] Related issues linked using 
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
  • Loading branch information
remorses authored and atilafassina committed Sep 5, 2022
1 parent aa441c2 commit 03813e1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/next/build/utils.ts
Expand Up @@ -1371,7 +1371,13 @@ export async function copyTracedFiles(
const symlink = await fs.readlink(tracedFilePath).catch(() => null)

if (symlink) {
await fs.symlink(symlink, fileOutputPath)
try {
await fs.symlink(symlink, fileOutputPath)
} catch (e: any) {
if (e.code !== 'EEXIST') {
throw e
}
}
} else {
await fs.copyFile(tracedFilePath, fileOutputPath)
}
Expand Down

0 comments on commit 03813e1

Please sign in to comment.