sentry-javascript-bundler-plugins icon indicating copy to clipboard operation
sentry-javascript-bundler-plugins copied to clipboard

setCommits in sentryWebpackPluginOptions for next.js doesn't seem to work on Vercel

Open jinsley8 opened this issue 3 years ago • 6 comments

Environment

SaaS (https://sentry.io/)

Version

No response

Steps to Reproduce

I have Sentry connected to Vercel and GIthub and the following next.config.js:

However, the Vercel build fails at the Sentry CLI step.

// eslint-disable-next-line
const { withSentryConfig } = require('@sentry/nextjs');
// eslint-disable-next-line
const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true',
});

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  poweredByHeader: false,
  swcMinify: true,
  compiler: {
    removeConsole: process.env.NODE_ENV === 'production',
  },
  },
  typescript: {
    ignoreBuildErrors: true,
  },
  sentry: {
    hideSourceMaps: true,
  },
};

const sentryWebpackPluginOptions = {
  silent: true, // Suppresses all logs

  setCommits: {
     repo: 'username/repo',
     auto: true,
     ignoreMissing: true,
  },
};

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

Expected Result

Expect to Vercel build to pass and to deploy.

Actual Result

- info  - Creating an optimized production build...
- Failed to compile.
- Sentry CLI Plugin: Command failed: /vercel/path0/node_modules/@sentry/cli/sentry-cli releases set-commits 9a08b86b.....364bc5fd67f --auto --ignore-missing
- error: No commits found. Change commits range, initial depth or use --ignore-empty to allow empty patch sets.
- > Build failed because of webpack errors
- error Command failed with exit code 1.
- - Error! Command "yarn run build" exited with 1

Not sure if it's failing because my config is incorrect or because Next.js using SWC as a default now instead of Webpack.

┆Issue is synchronized with this Jira Epic by Unito

jinsley8 avatar Sep 01 '22 21:09 jinsley8

Routing to @getsentry/ecosystem for triage. ⏲️

getsentry-release avatar Sep 02 '22 13:09 getsentry-release

This doesn't look like an issue with our Vercel integration. Rather this looks related to our webpack plugin https://github.com/getsentry/sentry-webpack-plugin or the underlying sentry-cli

Routing to @getsentry/sdks

NisanthanNanthakumar avatar Sep 08 '22 17:09 NisanthanNanthakumar

This doesn't look like an issue with our Vercel integration. Rather this looks related to our webpack plugin https://github.com/getsentry/sentry-webpack-plugin or the underlying sentry-cli

Routing to @getsentry/sdks

Should I repost this under the Sentry webpack repo?

jinsley8 avatar Sep 20 '22 14:09 jinsley8

Sorry, bot fail. 😞

chadwhitacre avatar Feb 15 '23 22:02 chadwhitacre

Hi, what I recommend doing here, and I do this in my side project too, is the following:

setCommits: {
  repo: 'lforst/my-repo',
  commit: process.env.VERCEL_GIT_COMMIT_SHA,
  previousCommit: process.env.VERCEL_GIT_PREVIOUS_SHA,
},

Note that auto can't be set. I think it fails because on Vercel the project is not inside a git repo anymore. We should maybe emit better error messages here and fail gracefully instead.

lforst avatar Nov 06 '23 15:11 lforst

Idea on how to fix this: We try-catch the setCommits command and log a warning/error with instructions on how to fix this. Actually.... Not sure yet if we should keep throwing or not. Throwing will definitely be more visible when you set up the plugin so we should maybe do that.

lforst avatar Nov 17 '23 09:11 lforst