Skip to content

Commit 639fc52

Browse files
piehascorbic
andauthored
chore: use win32 ebusy workaround on middleware-pages fixture (#328)
* chore: use win32 ebusy workaround on middleware-pages fixture * chore: ignore workflows --------- Co-authored-by: Matt Kane <[email protected]> Co-authored-by: Matt Kane <[email protected]>
1 parent fcf0afe commit 639fc52

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

.prettierignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ edge-runtime/vendor/
99
deno.lock
1010
tests/fixtures/simple-next-app-dist-dir/cool/output
1111
.nx
12-
custom-dist-dir
12+
custom-dist-dir
13+
# to avoid needing extra permissions to format files
14+
.github/workflows

tests/fixtures/middleware-pages/next.config.js

+23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
const { platform } = require('process')
2+
const fsPromises = require('fs/promises')
3+
4+
// Next.js uses `fs.promises.copyFile` to copy files from `.next`to the `.next/standalone` directory
5+
// It tries copying the same file twice in parallel. Unix is fine with that, but Windows fails
6+
// with "Resource busy or locked", failing the build.
7+
// We work around this by memoizing the copy operation, so that the second copy is a no-op.
8+
// Tracked in TODO: report to Next.js folks
9+
if (platform === 'win32') {
10+
const copies = new Map()
11+
12+
const originalCopy = fsPromises.copyFile
13+
fsPromises.copyFile = (src, dest, mode) => {
14+
const key = `${dest}:${src}`
15+
const existingCopy = copies.get(key)
16+
if (existingCopy) return existingCopy
17+
18+
const copy = originalCopy(src, dest, mode)
19+
copies.set(key, copy)
20+
return copy
21+
}
22+
}
23+
124
module.exports = {
225
trailingSlash: true,
326
output: 'standalone',

tests/fixtures/wasm/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { platform } = require('process')
22
const fsPromises = require('fs/promises')
33

4-
// Next.js uses `fs.promises.copyFile` to copy the `.wasm` file to the `.next` directory
4+
// Next.js uses `fs.promises.copyFile` to copy files from `.next`to the `.next/standalone` directory
55
// It tries copying the same file twice in parallel. Unix is fine with that, but Windows fails
66
// with "Resource busy or locked", failing the build.
77
// We work around this by memoizing the copy operation, so that the second copy is a no-op.

0 commit comments

Comments
 (0)