Unverified Commit abe53727 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Include page for export errors for easier debugging (#32013)

This makes sure to include the `page` for dynamic routes when they encounter an error during prerendering as we currently only include the `path`, e.g. before we would only show `/blog/first` and now we show `/blog/[slug]: /blog/first` 

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
parent cc9e1ea3
...@@ -600,7 +600,10 @@ export default async function exportApp( ...@@ -600,7 +600,10 @@ export default async function exportApp(
ampValidationResult.errors.length > 0) ampValidationResult.errors.length > 0)
} }
renderError = renderError || !!result.error renderError = renderError || !!result.error
if (!!result.error) errorPaths.push(path) if (!!result.error) {
const { page } = pathMap
errorPaths.push(page !== path ? `${page}: ${path}` : path)
}
if (options.buildExport && configuration) { if (options.buildExport && configuration) {
if (typeof result.fromBuildExportRevalidate !== 'undefined') { if (typeof result.fromBuildExportRevalidate !== 'undefined') {
......
...@@ -20,7 +20,6 @@ const runTests = () => { ...@@ -20,7 +20,6 @@ const runTests = () => {
expect(stderr).not.toContain('/amp') expect(stderr).not.toContain('/amp')
expect(stderr).not.toContain('/ssr') expect(stderr).not.toContain('/ssr')
expect(stderr).not.toContain('/ssg') expect(stderr).not.toContain('/ssg')
expect(stderr).not.toContain('/hello')
}) })
} }
......
export default function Page() {
throw new Error('oops')
}
export function getStaticProps() {
return {
props: {},
}
}
export function getStaticPaths() {
return {
paths: ['/blog/first', '/blog/second'],
fallback: false,
}
}
...@@ -19,5 +19,7 @@ describe('Handles Errors During Export', () => { ...@@ -19,5 +19,7 @@ describe('Handles Errors During Export', () => {
expect(stderr).toContain('/page-2') expect(stderr).toContain('/page-2')
expect(stderr).toContain('/page-3') expect(stderr).toContain('/page-3')
expect(stderr).toContain('/page-13') expect(stderr).toContain('/page-13')
expect(stderr).toContain('/blog/[slug]: /blog/first')
expect(stderr).toContain('/blog/[slug]: /blog/second')
}) })
}) })
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