Skip to content

Conversation

@lforst
Copy link
Contributor

@lforst lforst commented Nov 3, 2022

ATTENTION: Do not merge before this feature has shipped in the SDK

This PR adds a section to the Next.js troubleshooting guide on how to set up the SDK if you have API routes running on the Vercel Edge runtime.

@vercel
Copy link

vercel bot commented Nov 3, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
sentry-docs ✅ Ready (Inspect) Visit Preview Nov 3, 2022 at 2:19PM (UTC)

Copy link
Contributor

@lizokm lizokm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there! I'm Liza, the new docs manager. Apologies for this taking me a while to look over. I've made a few tweaks. Please let me know if you have any questions!

Comment on lines +457 to +484
The Sentry Next.js SDK does not yet support the [Vercel Edge Runtime](https://vercel.com/docs/concepts/functions/edge-functions) which is used in Next.js middleware and Edge Routes when deployed on Vercel.
If you want to use the Edge Runtime in combination with the Sentry SDK you need to manually opt the API routes that use the Edge Runtime out of Sentry instrumentation via the `excludedServersideEntrypoints` option in your `next.config.js`.

For example: Opting out the route `/api/posts` and all the routes starting with `/api/users/` will work like the following.

```javascript {filename:next.config.js}
const { withSentryConfig } = require("@sentry/nextjs");

const nextConfig = {
// Next.js configuration options...

sentry: {
excludedServersideEntrypoints: [
"pages/api/posts",
/^pages\/api\/users\/.*/,
],
// Other optional Sentry build-time configuration options...
},
};

const sentryWebpackPluginOptions = {
// Sentry Webpack Plugin options...
};

module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);
```

Please note that this will effectively disable the Sentry SDK for these API routes - removing all error and performance monitoring.
Copy link
Contributor

@lizokm lizokm Nov 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Sentry Next.js SDK does not yet support the [Vercel Edge Runtime](https://vercel.com/docs/concepts/functions/edge-functions) which is used in Next.js middleware and Edge Routes when deployed on Vercel.
If you want to use the Edge Runtime in combination with the Sentry SDK you need to manually opt the API routes that use the Edge Runtime out of Sentry instrumentation via the `excludedServersideEntrypoints` option in your `next.config.js`.
For example: Opting out the route `/api/posts` and all the routes starting with `/api/users/` will work like the following.
```javascript {filename:next.config.js}
const { withSentryConfig } = require("@sentry/nextjs");
const nextConfig = {
// Next.js configuration options...
sentry: {
excludedServersideEntrypoints: [
"pages/api/posts",
/^pages\/api\/users\/.*/,
],
// Other optional Sentry build-time configuration options...
},
};
const sentryWebpackPluginOptions = {
// Sentry Webpack Plugin options...
};
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);
```
Please note that this will effectively disable the Sentry SDK for these API routes - removing all error and performance monitoring.
The Sentry Next.js SDK doesn’t currently support [Vercel Edge Runtime](https://vercel.com/docs/concepts/functions/edge-functions) (which is used in Next.js middleware and Edge Routes when deployed on Vercel).
To use Edge Runtime in combination with the Sentry SDK, you'll need to manually opt out of the API routes that use the Edge Runtime in Sentry instrumentation using the `excludedServersideEntrypoints` option in your `next.config.js`.
For example: Opting out the route `/api/posts` and all the routes starting with `/api/users/` will work like this:
```javascript {filename:next.config.js}
const { withSentryConfig } = require("@sentry/nextjs");
const nextConfig = {
// Next.js configuration options...
sentry: {
excludedServersideEntrypoints: [
"pages/api/posts",
/^pages\/api\/users\/.*/,
],
// Other optional Sentry build-time configuration options...
},
};
const sentryWebpackPluginOptions = {
// Sentry Webpack Plugin options...
};
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);

Please note, this will effectively disable the Sentry SDK for these API routes and remove all error and performance monitoring.

@imatwawana imatwawana removed their request for review November 10, 2022 13:50
@lforst
Copy link
Contributor Author

lforst commented Nov 16, 2022

Superseded by #5789

@lforst lforst closed this Nov 16, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2022
@stephanie-anderson stephanie-anderson deleted the lforst-section-about-edge-runtime branch February 23, 2024 10:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants