question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Serverless function crashes for custom error page

See original GitHub issue

Verify 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

  1. clone the reproduction repo
  2. check out the error-handling-with-404-page branch
  3. deploy to Vercel
  4. visit the index
  5. 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:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ijjkcommented, Aug 29, 2022

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 serving pages/500.

Re-opening to investigate further

0reactions
github-actions[bot]commented, Sep 30, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom error page `_error.js` crashes only in Vercel if ... - GitHub
js works on a local build but it simply doesn't work after deploying on Vercel - it shows that Serverless Function crashed page....
Read more >
Error: This Serverless Function has crashed - Stack Overflow
I can't deploy my server in vercel. I get this error every time. What should I do?
Read more >
How do I handle errors in serverless applications? - AWS
Want to learn how to handle errors in serverless applications with AWS Step Functions? Learn how in in 10 minutes.
Read more >
A Comprehensive Guide To Error Handling In Node.js
If you fail to catch it, it becomes an uncaught exception, which may cause your application to crash!
Read more >
Error handling - Apollo GraphQL Docs
You can create a custom errors and codes using the graphql package's ... The formatError function does not modify errors that are sent...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found