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

ng build stuck after successful build since sentryWebpack v2

Open johanneszelger opened this issue 2 years ago • 23 comments

Since i upgraded from the plugin v1 to v2, my angular build gets stuck after a successfull build:

Build at: 2023-07-07T10:40:52.046Z - Hash: cc2971c88cd12369 - Time: 32093ms

just won't end the process after this line. When i remove the plugin, the build ends normally. I tried the plugin versions 2.4 2.3 2.0, all unsuccessfull.

johanneszelger avatar Jul 07 '23 10:07 johanneszelger

I have the same problem on Angular 15 app, when I add sentry webpack plugin I see success for build and sourcemap upload, but the process is not finished This makes the plugin not usable

niewicz avatar Jul 12 '23 09:07 niewicz

Hi, can you please share your plugin config? Do you get console output from the plugin regarding source maps upload or how many files were uploaded?

Lms24 avatar Jul 13 '23 18:07 Lms24

Sure, my config is:

plugins = [
  new webpack.DefinePlugin({
    "process.env.RELEASE": JSON.stringify(release),
    "process.env.BUILD": JSON.stringify(build)
  })
]

if (process.env.SENTRY_AUTH_TOKEN !== undefined && process.env.SENTRY_AUTH_TOKEN !== "") {
  console.log("adding sentry webpack because auth token was found, release: ", release)
  plugins.push(sentryWebpackPlugin({
    url: "url",
    org: "org",
    project: "frontend",

    authToken: process.env.SENTRY_AUTH_TOKEN,

    release: {
      name: release,
      finalize: false,
      cleanArtifacts: true,
      dist: build
    }
  }))
} else
  console.log("skipping sentry webpack because auth token was not found")

module.exports = {
  devtool: "source-map", // Source map generation must be turned on
  plugins: plugins,
  watch: false,
};

And yes i get output from the plugin, all sourcemaps are uploaded successfully, they are also visible on sentry. Everything is working - its just that my build pipeline gets stuck after the successfull build. If i cancel the process manually, everything works as expected.

johanneszelger avatar Jul 13 '23 18:07 johanneszelger

We have the same issue. It just doesn't end the webpack process

MitkoTschimev avatar Jul 17 '23 22:07 MitkoTschimev

I was able to pin it down to the dependency unplugin. For a simple plugin with this dep on the newest version shows the same behavior

https://github.com/unjs/unplugin/issues/323

MitkoTschimev avatar Jul 17 '23 23:07 MitkoTschimev

Thanks for investigating this @MitkoTschimev, appreciate the effort! Let's see if this can be fixed in unplugin. In the meantime, you might want to look into setting up Sentry-CLI to upload your source maps as a workaround.

Lms24 avatar Jul 20 '23 07:07 Lms24

It is unsuitable for us because we use service workers with angular. The service worker works based on the content hash value of artifacts. if we manipulate the files afterwards, they are not matching anymore.

This is the advantage of the webpack plugin.

we use at the moment version 1.x and its fine for us

MitkoTschimev avatar Jul 20 '23 08:07 MitkoTschimev

I am contemplating whether we should just remove unplugin entirely. In the beginning, I thought it was a good idea to abstract away all the bundler intricacies but by now many of the injection flows are different anyhow. I believe we're operating too low-level for unplugin to be effective. It would be a medium refactor but one dependency less.

lforst avatar Jul 24 '23 11:07 lforst

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

github-actions[bot] avatar Aug 15 '23 00:08 github-actions[bot]

I am contemplating whether we should just remove unplugin entirely. In the beginning, I thought it was a good idea to abstract away all the bundler intricacies but by now many of the injection flows are different anyhow. I believe we're operating too low-level for unplugin to be effective. It would be a medium refactor but one dependency less.

Is there any news yet?

johanneszelger avatar Aug 15 '23 13:08 johanneszelger

Hi, no news at this time. We're not gonna get to this this week. Maybe next week we can look into fixing this quickly in unplugin. Moving away from unplugin is a larger task I'm afraid and we're currently completely packed with tasks and projects.

Lms24 avatar Aug 23 '23 07:08 Lms24

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

github-actions[bot] avatar Sep 14 '23 00:09 github-actions[bot]

Any updates?

niewicz avatar Sep 27 '23 09:09 niewicz

No updates. I think we are soft-blocked by https://github.com/unjs/unplugin/issues/323. We could remove the unplugin dependency but it would result in quite a bit of work which we don't have the cycles for right now :(

lforst avatar Sep 29 '23 10:09 lforst

Any updates?

krema avatar Dec 12 '23 12:12 krema

@krema Not yet. You can use Sentry CLI to upload source maps for now. There also seems to be an issue with angular and esbuild in general. https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/351

lforst avatar Dec 12 '23 12:12 lforst

The documentation currently says to do what doesn't work. https://docs.sentry.io/platforms/javascript/guides/angular/sourcemaps/uploading/angular-webpack/

If there isn't bandwidth to remove unplugin, perhaps there is bandwidth to update the documentation with an alternative setup?

Because otherwise I will continue to use "@sentry/webpack-plugin": "^1.21.0", until this is resolved.

rgant avatar Feb 06 '24 14:02 rgant

@rgant Using "@sentry/webpack-plugin": "^1.21.0" is perfectly fine!

lforst avatar Feb 06 '24 14:02 lforst

Any news? This occurs to us too, however downgrading to ^1.21.0 isn't an option

Agrumas avatar Mar 26 '24 08:03 Agrumas

@Agrumas No news.

lforst avatar Mar 26 '24 13:03 lforst

This is still an issue. I've rolled back to ^1.21.0 for now, but wasted a good while trying to track this down :(

salonmonster avatar Aug 06 '24 20:08 salonmonster

Our workaround is to use the sentry-cli to upload the sourcemap with a specific release: Associating release with Artifact Bundle

gerbermichi avatar Aug 07 '24 07:08 gerbermichi

Yes, so the workaround is either to downgrade or to use sentry-cli. We are thinking of refactoring unplugin out but have not yet committed to it.

andreiborza avatar Aug 07 '24 11:08 andreiborza

Let's see if this can be fixed in unplugin

@Lms24 any update if this is fixable in unplugin? This came up internally from another org. Realistically i do not think we will remove unplugin in the near future.

Should we attempt a fix upstream? https://github.com/unjs/unplugin/issues/323#issuecomment-2208626770

smeubank avatar Jan 13 '25 17:01 smeubank

Hmm no updates from my end but the suggested fix sounds simple enough to give it a try! We can try first in our plugin (will do some testing) and if this works, we could submit a PR upstream.

Lms24 avatar Jan 13 '25 17:01 Lms24

I opened https://github.com/getsentry/sentry-javascript-bundler-plugins/pull/653 but no promises that this will get merged or work (cc @smeubank). As it stands, I actually cannot reproduce this issue locally in a simple Angular 14 test app that uses the Angular webpack builder and our plugin in the latest version.

If someone can provide a minimal reproduction (zip, GH issue, whatever else but please a buildable project), I'd appreciate it!

Lms24 avatar Jan 13 '25 18:01 Lms24

Something else I just came across: https://stackoverflow.com/a/63246847. Might be worth for anyone experiencing this issue to set watch explicitly. Again, I cannot reproduce this, so I can't help any further.

Lms24 avatar Jan 13 '25 18:01 Lms24

Angular v14 is really old and well past end of support. IIRC this was a problem with updating to v16 (based on the age of my original comment), and definately an issue with v17 (which is the oldest version still officially supported).

Also note that that SO post is also quite old and ejecting the Angular webpack config is no longer even a thing I believe. Not even sure if webpack is still much of a thing anymore: https://angular.dev/tools/cli/build-system-migration

rgant avatar Jan 13 '25 18:01 rgant

I'm well aware of Angular 14 being old :) However, https://github.com/unjs/unplugin/issues/323#issuecomment-2020010092 mentions NG14, so I thought I'd try to repro the bug on 14. Also aware of Webpack not being used anymore but afaik, you can still opt into using the webpack builder. Which anyone who's still coming across this problem must be using anyway :)

Lms24 avatar Jan 14 '25 07:01 Lms24

We released version 3.0.0 of the plugins. It includes a potential fix for the Angular build hanging (https://github.com/getsentry/sentry-javascript-bundler-plugins/pull/653). Would be great if anyone still affected by this can give it a try and report back. Thanks!

Lms24 avatar Jan 17 '25 13:01 Lms24