Skip to content

fix(nextjs): Add sentry-cli existence check for enabling webpack plugin #4311

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

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Dec 16, 2021

Our nextjs SDK uses sentry-cli (by way of SentryWebpackPlugin and @sentry/cli) to upload sourcemaps. Because binaries (like the sentry-cli executable) need to be compiled differently for different OSs and architectures, @sentry/cli uses a post-install script to download the correct one as part of its install process, rather than ship with all possible binaries at once.

Of course, this goes awry if the post-install script isn't run, which is exactly what happens when @sentry/cli is installed with the --ignore-scripts option. The resulting missing binary then causes errors which bubble up to and through our SDK to the nextjs build process, which promptly crashes.

This fixes that by checking to make sure they binary has been downloaded before enabling SentryWebpackPlugin.

Fixes getsentry/sentry-cli#1085.

@lobsterkatie lobsterkatie changed the title fix(nextjs): Add --ignore-scripts check for enabling webpack plugin fix(nextjs): Add sentry-cli existence check for enabling webpack plugin Dec 16, 2021
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.

slamming the ✅ for the unblock - but a quick question about where this check should live.

// architecture-specific version of the `sentry-cli` binary. If `yarn install`, `npm install`, or `npm ci` are run
// with the `--ignore-scripts` option, this will be blocked and the missing binary will cause an error when users
// try to build their apps.)
ensureCLIBinaryExists() &&
Copy link
Member

@AbhiPrasad AbhiPrasad Dec 16, 2021

Choose a reason for hiding this comment

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

Should we have this check in the webpack plugin? I assume it'll also be a problem for @sentry/gatsby (which does similar things)

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a good point. Really we should have it in sentry-cli itself. I went ahead and implemented that, but it's currently blocked on unrelated rust errors, so I'm going to merge this in for now. Once those rust problems are fixed (and everyone, including me, is back from winter break), we can switch to that implementation.

@github-actions
Copy link
Contributor

size-limit report

Path Base Size (1082ad6) Current Size Change
@sentry/browser - CDN Bundle (gzipped) 21.01 KB 21.01 KB +0.01% 🔺
@sentry/browser - CDN Bundle (minified) 66.97 KB 66.97 KB +0.01% 🔺
@sentry/browser - Webpack 22.79 KB 22.79 KB 0%
@sentry/browser - Webpack - gzip = false 78.2 KB 78.2 KB 0%
@sentry/react - Webpack 22.82 KB 22.82 KB 0%
@sentry/nextjs Client - Webpack 47.34 KB 47.34 KB 0%
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 29.35 KB 29.35 KB +0.01% 🔺

@lobsterkatie lobsterkatie merged commit 2f2d099 into master Dec 23, 2021
@lobsterkatie lobsterkatie deleted the kmclb-nextjs-disable-webpack-plugin-if-using-ignore-scripts branch December 23, 2021 06:19
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.

Sentry CLI Plugin ENOENT error with npm ci --ignore-scripts
2 participants