Serverless function crashes for custom error page
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
n/a
What browser are you using? (if relevant)
n/a
How are you deploying your application? (if relevant)
Vercel
Describe the Bug
With a local production build, a custom error page works as expected.
On Vercel, getInitialProps
is called for the custom error component, but the serverless function crashes, exiting with a Runtime.ExitError
and displaying a Vercel error page to users
2022-08-29T21:26:28.231Z 19727b2d-6d1f-49a4-99d6-fe1c36ad4616 ERROR Error: a test error has been manually triggered
at getServerSideProps (/var/task/.next/server/pages/index.js:21:11)
at Object.renderToHTML (/var/task/node_modules/next/dist/server/render.js:512:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async doRender (/var/task/node_modules/next/dist/server/base-server.js:638:38)
at async cacheEntry.responseCache.get.isManualRevalidate.isManualRevalidate (/var/task/node_modules/next/dist/server/base-server.js:743:28)
at async /var/task/node_modules/next/dist/server/response-cache/index.js:80:36 {
page: '/'
}
RequestId: 19727b2d-6d1f-49a4-99d6-fe1c36ad4616 Error: Runtime exited with error: exit status 1
Runtime.ExitError
This Serverless Function has crashed.
Your connection is working correctly.
Vercel is working correctly.
500: INTERNAL_SERVER_ERROR
Code: FUNCTION_INVOCATION_FAILED
ID: cle1::w2g9g-1661808388324-680c9cd47d8a
If you are a visitor, contact the website owner or try again later.
If you are the owner, [learn how to fix the error](https://vercel.com/docs/error/application/FUNCTION_INVOCATION_FAILED) and [check the logs](https://next-500-issue-44av6jqwb-evan-bnbfinderco.vercel.app/_logs).
Expected Behavior
I expect the getInitialProps
call to succeed, and the custom error component to be rendered successfully by the serverless function.
Link to reproduction
https://github.com/eprothro/next-500-issue/tree/error-handling-with-404-page
To Reproduce
- clone the reproduction repo
- check out the
error-handling-with-404-page
branch - deploy to Vercel
- visit the index
- see the
This Serverless Function has crashed
error page
Note that with this example repo, a commit adding a pages/404.tsx
page introduces the crash. You can check out the error-handling-no-404-page
branch and deploy to see the custom error component as expected. However, this is likely a red herring, as the application where we’re seeing this continues to experience the crash even when the pages/404.tsx
page is removed.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
If the behavior isn’t consistent when
pages/404
isn’t present/is then it sounds like a bug as it should always behave the same. It should also be calling_error.getInitialProps
if present before crashing and then servingpages/500
.Re-opening to investigate further
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.