Inconsistent behavior with showing intended error.tsx page versus Vercel "serverless function has crashed" page

Current versus Expected behavior

This has been dogging me for nearly 2 years and is nearly impossible to Google because of how it’s described.

Basically, I currently have an endpoint that throws a known error. Locally, this gives me the error boundary page we always intended.

When deployed on Vercel however, and contrary to the Next.js docs, this gives me the generic Vercel “serverless function has crashed” page.

I have never been able to figure out why it shows the Vercel page and not the page we intended. How do we get it to stop showing the Vercel crash page and show our own?

Thanks,
-Stephen

Bad:

Good:

(note: same path! querying same broken endpoint!)

Code, configuration, and steps that reproduce this issue

Project information

Deployment URL:
Environment (local, preview, production):
Project Framework:
Build Settings:
  Framework Preset:
  Build Command (if not default):
  Output Directory (if not default):
  Install Command (if not default):
Node/Runtime Version:
Package Manager:
Relevant Packages:

Hi, @stephenhmarsh! Welcome to the Vercel Community :smile:

That is odd. It could be due to a range of different reasons, I’d love to see a minimal reproducible example if you can provide one!

Otherwise, some troubleshooting tips:

  1. Review the logs to identify any specific errors related to the Serverless Function being invoked. You can find these logs at the host URL under the /_logs path.

  2. Review your function and make sure doesn’t contain any errors or infinite loops.

  3. If your function is taking too long to process a request, it might be timing out.

  4. If your function depends on environment variables, make sure they are correctly defined in your Preview and Production environments.

  5. Some packages with native dependencies might work locally but not in the Serverless Function environment. Look for alternative packages that achieve similar results without native dependencies.

Let us know how you get on!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.