getsentry / sentry-javascript-bundler-plugins

JavaScript Bundler Plugins for Sentry
https://sentry.io
BSD 3-Clause "New" or "Revised" License
126 stars 32 forks source link

Sentry Webpack Plugin `Warning: Didn't find any matching sources for debug ID upload.` #569

Open digicoffey opened 2 weeks ago

digicoffey commented 2 weeks ago

Environment

@sentry/react@7.65.0 @sentry/webpack-plugin@2.20.1

Steps to Reproduce

sentryWebpackPlugin({
  org: 'org',
  project: 'project',
  authToken: 'authToken',
  sourcemaps: {
    assets: './dist/**/*.js.map',
    rewriteSources: (source) => source,
  },
  release: {
    name: git.long(),
    inject: true,
    setCommits: {
      auto: true,
    },
    deploy: {
      env: 'env',
    },
  },
  reactComponentAnnotation: {
    enabled: true,
  },
}),

Expected Result

Sourcemaps are injected with a debug_id Sourcemaps are uploaded

Actual Result

Sourcemaps are not injected with a debug_id Sourcemaps are not uploaded

sentry-webpack-debug-id-upload-plugin[sentry-webpack-plugin] Warning: Didn't find any matching sources for debug ID upload. Please check the 'sourcemaps.assets' option.

Context

We have been using the sentry-cli to inject debug_id's and upload our sourcemaps:

sentry-cli sourcemaps inject ./dist
sentry-cli sourcemaps upload --release=release_hash ./dist --org=org --auth-token=token -p=project

We wanted to remove this step from our CI and integrate this as part of our build step using the @sentry/webpack-plugin plugin, but we haven't been able to get it working.

Our assumption, which could be incorrect, is that the inject: true property would handle the injection of the debug_id's, but the plugin can't seem to find them. We have tried changing our sourcemaps.assets to be more and less specific, but nothing seems to work.

If we provide the legacy property, ie:

uploadLegacySourcemaps: {
  paths: ['./public/dist'],
},

The upload of the sourcemaps works, but no debug_id's are injected. Any guidance/advice would be appreciated.

We realise that debug_id's are not mentioned in the documentation, but we thought that maybe the inject: true property would handle this?

lforst commented 2 weeks ago

Please try removing this option assets: './dist/**/*.js.map' entirely. Thanks!

(assets needs to be both .js files and .js.map files. Only doing .js.map will not work.)

digicoffey commented 2 weeks ago

Thanks for the response and the guidance, much appreciated.

I have removed the assets property completely, but I still get the same message and result.

[sentry-webpack-plugin] Debug: No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.
[sentry-webpack-plugin] Warning: Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.

Not sure if it something else in our webpack.config that could be preventing this to work? Is there anything you think we should check?

lforst commented 2 weeks ago

Hmm, that usually indicates that you are using something to side-step the normal asset emission by webpack. Which webpack version are you using?

Can you try setting the assets option to ['./dist/**/*']?

digicoffey commented 2 weeks ago

I tried your suggestion and am now getting a different issue, but at least it seems to be finding our sourcemaps.

Our webpack version is webpack@5.89.0.

The message we are getting now is:

[sentry-webpack-plugin] Debug: Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: /path/dist/app.min.js
lforst commented 2 weeks ago

Ok, that message means that one of the files the plugin found wasn't injected with debug IDs. Are you sure the file isn't a leftover from when you had a build before? Is that file part of your build output?

It's pretty hard to debug this just from debug messages. Would you mind sharing a minimal reproduction example? Depending on your webpack setup there may be third parties that mess with what our plugin does. (Our plugin doesn't do anything too funky so something else is likely doing something shady)

digicoffey commented 2 weeks ago

Apologies for the delay in getting back to you. Had a priority change today. I will try and get a minimal reproduction to you, but it won't be until next week as I have a few things I need to take care of.

There is quite a lot going on in our webpack, so I'm guessing there must be an issue in there somewhere.

Thanks for your advice and patience.