Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught errors in API routes or middleware functions are not reported #1055

Open
4 tasks
subzero10 opened this issue Apr 10, 2023 · 0 comments
Open
4 tasks
Assignees
Labels
nextjs @honeybadger-io/nextjs

Comments

@subzero10
Copy link
Member

subzero10 commented Apr 10, 2023

Description

Uncaught errors in API routes or middleware functions are not reported, because they reach our custom _error.js handler with status code 404 and have no context of the error.

Note: When using Pages Router these errors are not reported at all.

Note: When using App Router these errors are reported, either caught with the global window.onerror handler or with a very generic message.

Possible solution

  • Wrap all middleware functions and api handlers with a try/catch block that reports to Honeybadger. It would be great to do transparently with webpack rather than asking users to wrap all their functions with a try/catch (or a Honeybadger utility method).

TODO

  • Remove from limitations section in nextjs docs page and nextjs repo readme file when this is fixed.
  • Pages Router: Uncaught errors in API routes are reported to Honeybadger
  • Pages Router: Uncaught errors in middleware functions are reported to Honeybadger
  • App Router: Server errors are reported as expected, instead of a generic error message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nextjs @honeybadger-io/nextjs
Projects
None yet
Development

No branches or pull requests

1 participant