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) { ...@@ -412,7 +412,7 @@ export function getPageHandler(ctx: ServerlessHandlerCtx) {
if (err.code === 'ENOENT') { if (err.code === 'ENOENT') {
res.statusCode = 404 res.statusCode = 404
} else if (err.code === 'DECODE_FAILED') { } else if (err.code === 'DECODE_FAILED' || err.code === 'ENAMETOOLONG') {
// TODO: better error? // TODO: better error?
res.statusCode = 400 res.statusCode = 400
} else { } else {
......
...@@ -1255,7 +1255,7 @@ export default class Server { ...@@ -1255,7 +1255,7 @@ export default class Server {
return return
} }
} catch (err) { } catch (err) {
if (err.code === 'DECODE_FAILED') { if (err.code === 'DECODE_FAILED' || err.code === 'ENAMETOOLONG') {
res.statusCode = 400 res.statusCode = 400
return this.renderError(null, req, res, '/_error', {}) return this.renderError(null, req, res, '/_error', {})
} }
......
import { join, sep as pathSeparator, normalize } from 'path' import { join, sep as pathSeparator, normalize } from 'path'
import chalk from 'chalk' import chalk from 'chalk'
import { isWriteable } from '../../build/is-writeable'
import { warn } from '../../build/output/log' import { warn } from '../../build/output/log'
import { promises } from 'fs' import { promises } from 'fs'
import { denormalizePagePath } from '../../next-server/server/normalize-page-path' import { denormalizePagePath } from '../../next-server/server/normalize-page-path'
import { fileExists } from '../../lib/file-exists'
async function isTrueCasePagePath(pagePath: string, pagesDir: string) { async function isTrueCasePagePath(pagePath: string, pagesDir: string) {
const pageSegments = normalize(pagePath).split(pathSeparator).filter(Boolean) const pageSegments = normalize(pagePath).split(pathSeparator).filter(Boolean)
...@@ -31,14 +31,14 @@ export async function findPageFile( ...@@ -31,14 +31,14 @@ export async function findPageFile(
const relativePagePath = `${page}.${extension}` const relativePagePath = `${page}.${extension}`
const pagePath = join(rootDir, relativePagePath) const pagePath = join(rootDir, relativePagePath)
if (await isWriteable(pagePath)) { if (await fileExists(pagePath)) {
foundPagePaths.push(relativePagePath) foundPagePaths.push(relativePagePath)
} }
} }
const relativePagePathWithIndex = join(page, `index.${extension}`) const relativePagePathWithIndex = join(page, `index.${extension}`)
const pagePathWithIndex = join(rootDir, relativePagePathWithIndex) const pagePathWithIndex = join(rootDir, relativePagePathWithIndex)
if (await isWriteable(pagePathWithIndex)) { if (await fileExists(pagePathWithIndex)) {
foundPagePaths.push(relativePagePathWithIndex) 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