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

webpack plugin did not upload sourcemap when output.filename include contain a query

Open Jokcy opened this issue 2 years ago • 6 comments
trafficstars

Environment

What version are you running? Etc.

"@sentry/webpack-plugin": "^2.10.0", "@sentry/browser": "7.80.1", "@sentry/tracing": "7.80.1",

Steps to Reproduce

  1. use webpack plugin to upload sourcemap
  2. in output.filename add a query:
filename: `[name]${
                    isDev ? '' : '.[contenthash]'
                }.js?${APP_VERSION_QUERY_NAME}=${APP_VERSION}`,
  1. build use webpack, sentry did not upload sourcemap

Expected Result

sentry upload sourcemap

Actual Result

sentry did not upload sourcemap

Jokcy avatar Nov 15 '23 04:11 Jokcy

Thanks for reporting this. Maybe you have time to investigate why this is happening, if not we will take a look.

lforst avatar Nov 15 '23 08:11 lforst

Thanks for reporting this. Maybe you have time to investigate why this is happening, if not we will take a look.

I'm not familiar with the native part of the cli, I may make a repo that reproduce this issue to help you to investigate.

Jokcy avatar Nov 16 '23 00:11 Jokcy

+1 same problem

my situation

filename: '[name].js?[contenthash]',

leonidlebedev avatar Dec 07 '23 16:12 leonidlebedev

I am having a similar problem. The errors I'm getting are

[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: [...]/packages/web/.webpack/.assets/1080.c5621104137b49ba10db.js

I believe this is occurring because this injection code only works if the path ends with .js: https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/bbe047289daeb2373ed29c1fdd264927668ac4e4/packages/webpack-plugin/src/index.ts#L106-L113

Inside webpack, this regexp gets tested against chunk.files, which in my case contains the full filename, e.g. foo.js?bar

jtbandes avatar Mar 04 '24 20:03 jtbandes

I was able to work around this issue by patching the regular expression to look like this:

  include: /\.(js|ts|jsx|tsx|mjs|cjs)(?:\?|$)/

jtbandes avatar Mar 05 '24 07:03 jtbandes

@jtbandes Thanks for looking, it seems slightly risky for us to also match on queries in the end, I am not sure yet.

lforst avatar Mar 05 '24 08:03 lforst

Seems like https://github.com/getsentry/sentry-javascript-bundler-plugins/pull/597 resolves this - thanks for raising that @jtbandes. Closing for now then.

AbhiPrasad avatar Nov 01 '24 17:11 AbhiPrasad