Closed kylemcd closed 1 year ago
You're likely using some Next.js feature that is using Edge features (note: not "Vercel Edge Runtime" features). This could be middleware
or edge routes. We detect this usage and show the warning. sentry.edge.config.(js|ts)
is needed to instrument those edge features, regardless of whether or not you're running on the Vercel Edge Runtime or on some other runtime.
You're likely using some Next.js feature that is using Edge features (note: not "Vercel Edge Runtime" features). This could be
middleware
or edge routes. We detect this usage and show the warning.sentry.edge.config.(js|ts)
is needed to instrument those edge features, regardless of whether or not you're running on the Vercel Edge Runtime or on some other runtime.
Gotcha, that makes sense. I guess I just automatically associate "Edge" with a Vercel / Netlify hosted solution.
Thanks for answering! Wasn't sure if there were any downstream effects of adding that config.
Yeah unfortunately Vercel/Next.js docs conflates using Vercel with using edge routes/middleware quite a bit (same with the new app directory), making it hard to understand what works where. @lforst had to even make a big matrix to track this for our sdk (https://github.com/getsentry/sentry-javascript/issues/6120).
Hi @lforst we are running into this also, and I'm fairly sure we're not using any edge features.
We already have Sentry client set up, which we manually init in a SentryErrorClient
class constructor, depending on some env vars, and this has been working fine to send uncaught and manually-traced exceptions to Sentry.
I am now looking to add source map support, and am following the manual configuration guide here: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
Here is a minimal repro, with these deps:
"@sentry/nextjs": "^7.48.0",
"@sentry/react": "^7.48.0",
"@sentry/tracing": "^7.48.0",
"next": "^13.3.0",
next.config.js:
const { withSentryConfig } = require('@sentry/nextjs');
const nextConfig = {
productionBrowserSourceMaps: true,
sentry: {
hideSourceMaps: true,
},
};
const sentryWebpackPluginOptions = {
silent: true,
};
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);
Running 'next build' gives this error:
[@sentry/nextjs] You are using Next.js features that run on the Edge Runtime. Please add a "sentry.edge.config.js" or a "sentry.edge.config.ts" file to your project root in which you initialize the Sentry SDK with "Sentry.init()".
> Build error occurred
Error: Cannot find 'sentry.server.config.ts' or 'sentry.server.config.js' in [...]
Any ideas how I can debug to understand which features Sentry thinks are Next edge ones? Thanks
Update: the "You are using Next.js features that run on the Edge Runtime" warning might be a misleading red herring.
I added 3x new config ts files for client, server, edge that do export {}
and this seems to have gotten around the warning.
I do now get an autogenerated release tag for events though coming through into the sentry project now though! And if I add the SENTRY_ORG, SENTRY_PROJECT, SENTRY_AUTH_TOKEN env vars the sourcemap upload works properly.
The above two steps not mentioned in the nextjs guide, took me a while to figure out.
@alextreppass
We already have Sentry client set up, which we manually init in a SentryErrorClient class constructor, depending on some env vars, and this has been working fine to send uncaught and manually-traced exceptions to Sentry.
Does this work for your server-side code?
Any ideas how I can debug to understand which features Sentry thinks are Next edge ones? Thanks
middleware, and everything where you manually set
export const config = {
runtime: 'edge',
}
Does this work for your server-side code?
We don't have much server-side yet (intentionally, as we're starting with cross-platform native apps), so are not using server-side sentry reporting yet. We'll invest later.
middleware, and everything where you manually set
No middleware present AFAICT — the warning appears with the virtually-empty Next config mentioned above. We are not using edge runtime for anything either.
I'm unblocked for now, just wanted to flag about the warning message being a red-herring, and that I had to create empty export {}
sentry config files (client, server, edge) to get sourcemaps uploading — this wasn't mentioned in the docs.
Thanks
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g.
bundle.tracing.min.js
) in your SDK setup.@sentry/nextjs
SDK Version
7.47.0
Framework Version
Next 13.3.0, React 18.2.0
Link to Sentry event
No response
SDK Setup
// This file configures the initialization of Sentry on the browser. // The config you add here will be used whenever a page is visited. // https://docs.sentry.io/platforms/javascript/guides/nextjs/
import * as Sentry from '@sentry/nextjs'; import pjson from './package.json';
const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
Sentry.init({ dsn: SENTRY_DSN, // Adjust this value in production, or use tracesSampler for greater control tracesSampleRate: 1.0, release: 'foxtrotWeb@' + pjson.version, ignoreErrors: [ 'Non-Error promise rejection captured', 'Illegal invocation', 'Request failed with status code 401', 'Cannot read properties of null', "null is not an object (evaluating 'el.parentNode.removeChild')", "null is not an object (evaluating 'el.closest')", "undefined is not an object (evaluating 'flkty.remove')", "Cannot read property 'remove' of undefined", "Cannot read properties of undefined (reading 'remove')", 'el.parentNode is null', "undefined is not an object (evaluating 't.args.push')", "Cannot read properties of undefined (reading 'push')", "Cannot read property 'removeChild' of null", "Cannot read property 'closest' of null", 'flkty is undefined', 'LaunchDarklyFlagFetchError', 'AbortError: The operation was aborted.', 'Non-Error exception captured with keys: config, data, headers, request, status', 'A network error occurred.', 'Non-Error exception captured with keys: error', 'Could not load "places_impl".', 'Network Error', 'Non-Error exception captured with keys: details, error', 'Request aborted', 'Bad request', 'Request failed with status code 404', ] });
Steps to Reproduce
next build
Expected Result
I would expect not to see that message in logs as I'm running this process on a
render.com
env where edge wouldn't be supported. I do not use next middleware or next edge api routes.Actual Result
I see this message in the logs on
next build