Skip to content

feat(nextjs): Don't init SDK on Vercel Edge Runtime #6408

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

Merged
merged 5 commits into from
Dec 5, 2022

Conversation

lforst
Copy link
Contributor

@lforst lforst commented Dec 5, 2022

This PR fixes a problem where we crash out of the box on Vercel and also in production builds when the experimental-edge runtime is used in API routes.

We use the fact that Next.js string replaces the global EdgeRuntime when a server bundle is supposed to be run on the edge runtime. If this is the case we no-op Sentry.init and log a message. We also have to not wrap the API routes automatically in that case.

Tried to add quick tests that test if the API routes still crash. But with our integration test setup it was a pita to get working because this is only really a thing for Next.js 12+.

Ref: #6346

@lforst lforst requested a review from lobsterkatie December 5, 2022 10:28
@lforst lforst marked this pull request as ready for review December 5, 2022 10:28
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.6 KB (-0.01% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 60.69 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.37 KB (+0.01% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 54.26 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 20.13 KB (0%)
@sentry/browser - Webpack (minified) 65.83 KB (0%)
@sentry/react - Webpack (gzipped + minified) 20.16 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.01 KB (+0.11% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.44 KB (+0.01% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.87 KB (+0.02% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 41.74 KB (0%)
@sentry/replay - Webpack (gzipped + minified) 37.23 KB (0%)

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

LGTM

@AbhiPrasad AbhiPrasad merged commit 2fbaf45 into master Dec 5, 2022
@AbhiPrasad AbhiPrasad deleted the lforst-dont-init-nextjs-sdk-on-edge-runtime branch December 5, 2022 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants