Skip to content

Commit 273b021

Browse files
committed
fix: handle error and remove patch
1 parent 739e513 commit 273b021

File tree

2 files changed

+5
-30
lines changed

2 files changed

+5
-30
lines changed

src/helpers/files.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ exports.moveStaticPages = async ({ netlifyConfig, target, i18n }) => {
6464
const source = join(root, file)
6565
files.push(file)
6666
const dest = join(netlifyConfig.build.publish, file)
67-
await move(source, dest)
67+
try {
68+
await move(source, dest)
69+
} catch (error) {
70+
console.warn('Error moving file', source, error)
71+
}
6872
}
6973
// Move all static files, except error documents and nft manifests
7074
const pages = await globby(['**/*.{html,json}', '!**/(500|404|*.js.nft).{html,json}'], {

src/templates/getHandler.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable max-lines-per-function, max-lines */
21
const { promises, createWriteStream, existsSync } = require('fs')
32
const { Server } = require('http')
43
const { tmpdir } = require('os')
@@ -35,8 +34,6 @@ const makeHandler =
3534
const cacheDir = path.join(tmpdir(), 'next-static-cache')
3635
// Grab the real fs.promises.readFile...
3736
const readfileOrig = promises.readFile
38-
const writeFileOrig = promises.writeFile
39-
const mkdirOrig = promises.mkdir
4037
// ...then money-patch it to see if it's requesting a CDN file
4138
promises.readFile = async (file, options) => {
4239
// We only care about page files
@@ -45,10 +42,6 @@ const makeHandler =
4542
const filePath = file.slice(pageRoot.length + 1)
4643
const cacheFile = path.join(cacheDir, filePath)
4744

48-
if (existsSync(cacheFile)) {
49-
return readfileOrig(cacheFile, options)
50-
}
51-
5245
// Is it in the CDN and not local?
5346
if (staticFiles.has(filePath) && !existsSync(file)) {
5447
// This name is safe to use, because it's one that was already created by Next
@@ -74,27 +67,6 @@ const makeHandler =
7467

7568
return readfileOrig(file, options)
7669
}
77-
78-
promises.writeFile = async (file, data, options) => {
79-
if (file.startsWith(pageRoot)) {
80-
const filePath = file.slice(pageRoot.length + 1)
81-
const cacheFile = path.join(cacheDir, filePath)
82-
await promises.mkdir(path.dirname(cacheFile), { recursive: true })
83-
return writeFileOrig(cacheFile, data, options)
84-
}
85-
86-
return writeFileOrig(file, data, options)
87-
}
88-
89-
promises.mkdir = async (dir, options) => {
90-
if (dir.startsWith(pageRoot)) {
91-
const filePath = dir.slice(pageRoot.length + 1)
92-
const cachePath = path.join(cacheDir, filePath)
93-
return mkdirOrig(cachePath, options)
94-
}
95-
96-
return mkdirOrig(dir, options)
97-
}
9870
}
9971
let NextServer
10072
try {
@@ -210,4 +182,3 @@ exports.handler = ${
210182
`
211183

212184
module.exports = getHandler
213-
/* eslint-enable max-lines-per-function, max-lines */

0 commit comments

Comments
 (0)