Skip to content

fix(nextjs): Use env variable for build detection #4608

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 3 commits into from
Feb 23, 2022

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Feb 18, 2022

In non-Vercel-deployed nextjs apps using our SDK, we instrument the server in order to be able to capture transactions for a wider variety of incoming requests than is possible using our withSentry API route handler wrapper. We don't do this during build, however, because there's no server to wrap.

Until now, we've been relying on the fact that child processes of the main build process were invoked by node <path>/node_modules/jest-worker/build/workers/processChild.js in order to recognize them as such. Recently, however, next started vendoring pre-compiled versions of more of its dependencies, including jest-worker, such that now those child process are invoked by node <path>/node_modules/next/dist/compiled/jest-worker/processChild.js. This broke our build detection.

Rather than just switch to using the new path, this PR refactors the check to use an env variable set by the main build process, in order that the check not get fooled by any child processes spawned at runtime. (I don't actually know if that ever happens, but there's no reason it couldn't, so better to have a foolproof indicator.)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 18, 2022

size-limit report

Path Base Size (8e4e671) Current Size Change
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.7 KB 19.7 KB -0.01% 🔽
@sentry/browser - ES5 CDN Bundle (minified) 63.31 KB 63.31 KB 0%
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.37 KB 18.37 KB -0.03% 🔽
@sentry/browser - ES6 CDN Bundle (minified) 56.48 KB 56.48 KB 0%
@sentry/browser - Webpack (gzipped + minified) 22.16 KB 22.16 KB 0%
@sentry/browser - Webpack (minified) 76.18 KB 76.18 KB 0%
@sentry/react - Webpack (gzipped + minified) 22.19 KB 22.19 KB 0%
@sentry/nextjs Client - Webpack (gzipped + minified) 46.33 KB 46.33 KB 0%
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 27.16 KB 27.15 KB -0.01% 🔽

@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-fix-build-detection branch from 6ade410 to 83a7654 Compare February 18, 2022 18:27
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.

:shipit:

@lobsterkatie lobsterkatie enabled auto-merge (squash) February 23, 2022 14:40
@lobsterkatie lobsterkatie merged commit d3e6f5c into master Feb 23, 2022
@lobsterkatie lobsterkatie deleted the kmclb-nextjs-fix-build-detection branch February 23, 2022 14:51
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