Skip to content

Commit

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

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 #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 committed Sep 1, 2022
1 parent 2de7b43 commit 57fdff1
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 57fdff1

Please sign in to comment.