-
-
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 working on server #3691
Comments
@cyrus-za Thanks for reporting this. What version of nextjs are you using, and which version of webpack? Also, can you clarify, are you using |
Some more info here:
|
Same issue here. Just tried upgrading to next 11. I've only tried starting my nextjs app in dev mode so far. I get the same log messages as @ckychris, reproduced here:
My app does indeed start, and everything looks normal. One thing to note: in dev mode, when const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const isProd = process.env.NODE_ENV === 'production';
const { withSentryConfig } = require('@sentry/nextjs');
const SentryWebpackPluginOptions = {
authToken: process.env.SENTRY_AUTH_TOKEN,
setCommits: {
commit: process.env.APP_VERSION,
repo: process.env.SENTRY_REPO,
},
};
const nextConfig = {
target: 'server',
webpack5: true,
poweredByHeader: false,
productionBrowserSourceMaps: true,
publicRuntimeConfig: {
apiHost: process.env.API_HOST,
// ... other env variables
},
};
const sentryConfig = isProd ? withSentryConfig(nextConfig, SentryWebpackPluginOptions) : nextConfig;
console.log(isProd ? 'using sentry config wrapper' : 'not using sentry config wrapper');
module.exports = withBundleAnalyzer(sentryConfig); Edit: i also get this same error/warning when creating a production build and running the prod server via |
Same issue as @neilpoulin here after updating to Next 11 and running |
I had the same issue with next 10.2.2. I had to add webpack 5 support: // This file sets a custom webpack configuration to use your Next.js app
// with Sentry.
// https://nextjs.org/docs/api-reference/next.config.js/introduction
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
const { withSentryConfig } = require("@sentry/nextjs");
const moduleExports = {
// Your existing module.exports
future: {
webpack5: true,
},
};
const SentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, org, project, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
};
// Make sure adding Sentry options is the last code to run before exporting, to
// ensure that your source maps include changes from all other Webpack plugins
module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions); now it catches error from API routes EditBut still, it doesn't catch errors on production build... It only works when calling |
Same issue here, using
|
The error |
Calling See UnlyEd/next-right-now#375 Also, I recommend wrapping "flush" into try/catch, as it throws exception under some race conditions. See #3748 and https://github.com/UnlyEd/next-right-now/blob/v2-mst-aptd-at-lcz-sty/src/modules/core/sentry/universal.ts#L56-L63 for implementation example. |
We're also seeing
|
Just wanted to add, v6.8.0 does not solve this problem. |
Hi @baptisteArno,
Which "in the function file directly" do you mean? Can you explain that to me in more detail, please? I have some issues getting |
I mean calling init before your Next.js handler function (any file in api folder) |
Ok, but everything else works as expected on Vercel for you? |
Hi, all. There were two problems causing this, I believe, one of them fixed here (already released) and one of them fixed here (should be released tomorrow, as 6.10.0). Once that release is published, can you all please try upgrading, and let us know if you're still having trouble? I'm going to close this in the meantime, but please do reach out if you have further problems. Thanks! |
Package + Version
@sentry/browser
@sentry/node
raven-js
raven-node
(raven for node)Version:
Description
When I scafold a nextjs app (using nx workspaces, but probably unrelated) and add sentry to it, the frontend works just fine, but running
next dev
results in pages/api/* routes not logging to sentry. I do use the withSentry wrapper around my handlers, but it appears that Sentry.init never gets called despite sentry.server.config.js being configured. Calling it manually right outside the handler fixes it, so it's definitely got to do with the cli not calling init. I am guessing the init gets called during webpack builds which is configured to only run in production (I dont want to upload source maps for local dev).The text was updated successfully, but these errors were encountered: