nuxt-community / sentry-module

Sentry module for Nuxt 2
https://sentry.nuxtjs.org
MIT License
501 stars 114 forks source link

Should build fail if `publishRelease` fail because Sentry instance is down ? #584

Closed mrleblanc101 closed 1 year ago

mrleblanc101 commented 1 year ago

Hi, Should build fail if publishRelease fail because Sentry instance is down ? I'm trying to deploy my app, and our self-hosted Sentry is currently down. I can't deploy because I have publishRelease: true which fails. Should we have an option to ignore this is complete the build ?

rchl commented 1 year ago

I think you might be able to do that already using the publishRelease.errorHandler option. It's part of Sentry own types and is documented as:

    /**
     * When a CLI error occurs, the plugin will call this function.
     *
     * By default, it will call `invokeErr()`, thereby stopping Webpack
     * compilation. To allow compilation to continue and log a warning instead,
     * set this to
     *   (err, invokeErr, compilation) => {
     *     compilation.warnings.push('Sentry CLI Plugin: ' + err.message)
     *   }
     *
     * Note: `compilation` is typed as `unknown` in order to preserve
     * compatibility with both Webpack 4 and Webpack 5 types, If you need the
     * correct type, in Webpack 4 use `compilation.Compilation` and in Webpack 5
     * use `Compilation`.
     */
    errorHandler?: (
      err: Error,
      invokeErr: () => void,
      compilation: unknown
    ) => void;

BTW. There is also this Nuxt issue that causes Sentry errors during publishing to be hidden: https://github.com/nuxt/nuxt/issues/21284 Not sure if you were also hit by this and had to guess what the issue is when it happened?

mrleblanc101 commented 1 year ago

@rchl Thanks for the tip, will try ! The error seems to work for me: Capture d’écran, le 2023-06-12 à 10 17 58 Which is indeed caused by the fact that our self-hosted Sentry is down: Capture d’écran, le 2023-06-12 à 10 22 40

mrleblanc101 commented 1 year ago

I was not able to make it work. I tried both in my nuxt.config.js:

sentry: {
    config: {
        errorHandler: (err, invokeErr, compilation) => {
            compilation.warnings.push('Sentry CLI Plugin: ' + err.message);
        },
    },
},

And

sentry: {
      errorHandler: (err, invokeErr, compilation) => {
          compilation.warnings.push('Sentry CLI Plugin: ' + err.message);
      },
},
rchl commented 1 year ago
sentry: {
  publishRelease: {
    errorHandler: ...
  }
}
mrleblanc101 commented 1 year ago

@rchl The only possibility I didn't try I guess 😅 Thanks, I searched in the Sentry documentation instead of the sentry-webpack-plugin documentation.