@sentry/nextjs not reporting errors in next.js api routes on vercel
See original GitHub issue- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
- Provide a link to the affected event from your Sentry account
Package + Version
-
@sentry/browser
-
@sentry/node
-
raven-js
-
raven-node
(raven for node) - other:
@sentry/nextjs
Version:
6.17.3
Description
Errors from my frontend using the Throw Error
button and errors from my api routes (/subscribe
, /twitch
) are not working. When pressing the Throw Error
button referenced in your documentation, I do not see any network requests going to Sentry. In the api routes, I am seeing my fake error shown in the logs, but again nothing is sent to Sentry.
I have the following environment variables defined in Vercel.
SENTRY_DSN
SENTRY_PROJECT
SENTRY_ORG
SENTRY_URL
SENTRY_AUTH_TOKEN
You can view the source code in the repository, and check out the live demo on the website.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Next.js - Sentry Documentation
On this page, we get you up and running with Sentry's SDK, so that it will automatically report errors and exceptions in your...
Read more >Next.js With Sentry Example - StackBlitz
This is an example showing how to use [Sentry]. (https://sentry.io) to catch and report. errors and monitor the performance of both.
Read more >Advanced Features: Error Handling - Next.js
Handle errors in your Next.js app. ... It is only visible when the development server runs using next dev , npm run dev...
Read more >Manual Setup for Next.js - DocBase AI Documentation
If you want to instrument Next.js API Routes , which run on serverless, ... done by @sentry/nextjs doesn't run, and therefore certain errors...
Read more >Deploy and Monitor your Next.js Applications with ... - YouTube
Richard Propst (Solutions Engineer @Sentry) and Lee Robinson (Developer Relations @ Vercel ) walk through how to build, deploy, and monitor ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@rfdearborn Hi, admittedly that is a use case we haven’t fully explored yet.
The
@sentry/nextjs
SDK does a few things under the hood that you would need to do manually here.First, you probably need to call
Sentry.init()
in the scope of your API route (not in the handler) so the SDK gets initialized. In the/pages
folder this happens automatically.Next, you will probably need to wrap your route handler in
withSentryAPI
. This is so that errors are properly recorded.I haven’t actually done this yet but this is what I would try first. If you want and have the time you could open a separate issue so we can properly track this feature request and gauge interest.
I wrote a new issue! https://github.com/getsentry/sentry-javascript/issues/6450