-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
@sentry/nextjs not reporting errors in next.js api routes on vercel #4479
Comments
Hey thanks for opening an issue! We did a little investigating here and it seems like it all works fine locally. We then took a look at your client-side code on your deployed site and enabled debug mode. (Every Sentry SDK has a debug mode which enables the debug logger) - and it seems that the SDK is never initialized because there is no valid DSN provided. The SDK is no-op when there is no dsn, and this is probably happening to your API routes as well! To make sure this isn't something on our end (since we dynamically inject the sentry configs through webpack), could you check that you set the If that doesn't go anywhere, it would be great if you could turn on debug mode and do a deploy to Vercel. This will allow us to debug further! Sentry.init({
debug: true,
// pass whatever other options you have
}); |
Thanks for following up @AbhiPrasad. I went ahead and committed some changes to enable
|
A lightbulb went on and I thought it might be because I'm not prefixing my environment variable with However I'm still not seeing anything coming from my API routes. |
Hi, @bradgarropy. Glad to hear front end errors are working now! I'm curious, because this recently came up elsewhere, where are you setting that DSN env variable? And are you setting it with the As to your API routes, can you confirm that nextjs picks them up, and will direct requests to them? (I cloned and tried to build yours to test it, but couldn't get past a number of build errors.) When I move my |
Hey @lobsterkatie, I'm hosted on Vercel, so I defined my environment variable there, as But, I think I just found the actual root cause. Vercel supports serverless functions out of a top level After moving my api routes into the Next.js application, Sentry is working just fine! Thanks for your support and I'll close the issue. |
Hey folks - within our Next.js Vercel project, we've recently moved API routes from |
@rfdearborn Hi, admittedly that is a use case we haven't fully explored yet. The First, you probably need to call Next, you will probably need to wrap your route handler in 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. |
Any update? I'm have the same problem. |
@Jay-flow we need more information. Can you open another issue with steps to reproduce your problem? |
Package + Version
@sentry/browser
@sentry/node
raven-js
raven-node
(raven for node)@sentry/nextjs
Version:
Description
Errors from my frontend using the
Throw Error
button and errors from my api routes (/subscribe
,/twitch
) are not working. When pressing theThrow 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.
You can view the source code in the repository, and check out the live demo on the website.
The text was updated successfully, but these errors were encountered: