Unverified Commit 9e87596b authored by Darsh Patel's avatar Darsh Patel Committed by GitHub

Fix: Non-writable pages/_app breaks build (#24849)

Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent 86827058
......@@ -412,7 +412,7 @@ export function getPageHandler(ctx: ServerlessHandlerCtx) {
if (err.code === 'ENOENT') {
res.statusCode = 404
} else if (err.code === 'DECODE_FAILED') {
} else if (err.code === 'DECODE_FAILED' || err.code === 'ENAMETOOLONG') {
// TODO: better error?
res.statusCode = 400
} else {
......
......@@ -1255,7 +1255,7 @@ export default class Server {
return
}
} catch (err) {
if (err.code === 'DECODE_FAILED') {
if (err.code === 'DECODE_FAILED' || err.code === 'ENAMETOOLONG') {
res.statusCode = 400
return this.renderError(null, req, res, '/_error', {})
}
......
import { join, sep as pathSeparator, normalize } from 'path'
import chalk from 'chalk'
import { isWriteable } from '../../build/is-writeable'
import { warn } from '../../build/output/log'
import { promises } from 'fs'
import { denormalizePagePath } from '../../next-server/server/normalize-page-path'
import { fileExists } from '../../lib/file-exists'
async function isTrueCasePagePath(pagePath: string, pagesDir: string) {
const pageSegments = normalize(pagePath).split(pathSeparator).filter(Boolean)
......@@ -31,14 +31,14 @@ export async function findPageFile(
const relativePagePath = `${page}.${extension}`
const pagePath = join(rootDir, relativePagePath)
if (await isWriteable(pagePath)) {
if (await fileExists(pagePath)) {
foundPagePaths.push(relativePagePath)
}
}
const relativePagePathWithIndex = join(page, `index.${extension}`)
const pagePathWithIndex = join(rootDir, relativePagePathWithIndex)
if (await isWriteable(pagePathWithIndex)) {
if (await fileExists(pagePathWithIndex)) {
foundPagePaths.push(relativePagePathWithIndex)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment