Skip to content

Commit

Permalink
chore: add extra error info for rsc info helper
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Aug 26, 2023
1 parent eca06a5 commit 55e5e42
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/next/src/build/analysis/get-page-static-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,9 @@ async function tryToReadFile(filePath: string, shouldThrow: boolean) {
return await fs.readFile(filePath, {
encoding: 'utf8',
})
} catch (error) {
} catch (error: any) {
if (shouldThrow) {
error.message = `Next.js ERROR: Failed to read file ${filePath}:\n${error.message}`
throw error
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2865,7 +2865,6 @@ export default async function build(

// If there's /not-found inside app, we prefer it over the pages 404
if (hasStaticApp404) {
// await moveExportedPage('/_error', '/404', '/404', false, 'html')
await moveExportedAppNotFoundTo404()
} else {
// Only move /404 to /404 when there is no custom 404 as in that case we don't know about the 404 page
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/server/lib/find-page-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function createValidFileMatcher(
pageExtensions
)}$`
)
const leafOnlyNotFoundFileRegex = new RegExp(
const rootNotFoundFileRegex = new RegExp(
`^not-found\\.${getExtensionRegexString(pageExtensions)}$`
)
/** TODO-METADATA: support other metadata routes
Expand Down Expand Up @@ -136,7 +136,7 @@ export function createValidFileMatcher(
return false
}
const rest = filePath.slice(appDirPath.length + 1)
return leafOnlyNotFoundFileRegex.test(rest)
return rootNotFoundFileRegex.test(rest)
}

return {
Expand Down

0 comments on commit 55e5e42

Please sign in to comment.