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

`sourcemaps.rewriteSources` doesn’t apply new source value

Open niksy opened this issue 1 year ago • 3 comments

Environment

  • Sentry Vite plugin, 2.16.1
  • Self hosted Sentry, 22.8.0

Steps to Reproduce

  1. Use Sentry Vite plugin
  2. Add option sourcemaps.rewriteSources: (source) => './' + source.replace('../', '')

Expected Result

Source from source map should be translated to value defined in rewriteSources hook, e.g. ../ should be stripped and ./ should be prepended to source path.

Actual Result

Default value is used which is relative path from process.cwd(), but I’m not sure if that’s valid - I’ve tried to change code directly inside default hook but changes are not applied.

I’m also using RewriteFrames integration, but I haven’t seen any changes if it’s removed.

Is this maybe related to self-hosted Sentry? For upload to work I had to use release.uploadLegacySourcemaps option so maybe these changes don’t get applied?

niksy avatar May 15 '24 13:05 niksy

Hey @niksy thanks for writing in!

To debug this, would you mind sharing your vite plugin config?

It could be well-related to self-hosted and uploadLegacySourcemaps. Which makes this extra hard to debug 😅 are you able to update to the latest self-hosted version of Sentry? If so, I think the simpler, debug-id based source map upload apporach should work (tagging @lforst to confirm).

Lms24 avatar May 16 '24 09:05 Lms24

To debug this, would you mind sharing your vite plugin config?

Sure, no problem, here it is:

sentryVitePlugin({
  url: "",
  org: "",
  project: "",
  authToken: "",
  sourcemaps: {
    rewriteSources: (source) => "./" + source.replaceAll("../", ""),
  },
  release: {
    name: commitSha,
    uploadLegacySourcemaps: path.resolve(cwd, "ssr-dist"),
  },
});

are you able to update to the latest self-hosted version of Sentry?

I’ll see what I can do, it would be great if this is fixed just with version bump, it looks like our self-hosted instance version is almost 2 years old 😄

niksy avatar May 16 '24 13:05 niksy

Unfortunately, we’re currently unable to easily upgrade our Sentry instance 😞

niksy avatar May 17 '24 08:05 niksy

One question: Did you look at the sources field of the uploaded artifact (in Sentry) or the local file? sourcemaps.rewriteSources only affects the uploaded artifacts.

lforst avatar May 21 '24 08:05 lforst

@lforst I’ve looked in both places, local and I’ve downloaded uploaded artifact - there isn’t any rewrite done for paths.

I suppose this is something that Sentry Vite plugin should be doing?

niksy avatar May 21 '24 10:05 niksy

@niksy okay thank you! I will take a look.

lforst avatar May 21 '24 11:05 lforst

@niksy Hey, I just took another look. I realized you were using uploadLegacySourcemaps to upload the source maps. The upload process that is kicked off when using that option does not consider any options in the sourcemaps field. If you want to transform sourcemaps when using uploadLegacySourcemaps, I recommend looking into the specific options instead.

I think we can do a better job documenting this. Sorry about that.

lforst avatar May 23 '24 11:05 lforst

Okay, thank you for a fast response!

niksy avatar May 24 '24 07:05 niksy