I have a custom _error.tsx page in in my nextjs project to show 500 errors and to log the errors to Sentry. It works locally when I run the project in production mode with next build + next start, but whenever I deploy the app to Vercel I get a generic “EDGE_FUNCTION_INVOCATION_FAILED” error page whenever the app encounters 500 errors - effectively bypassing my custom error page:
These changes should help you handle both regular 500 errors and middleware errors on Vercel. Give it a shot and let me know if you need any more help!