Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: The source map is not working on Sentry #7914

Open
cjnoname opened this issue Sep 17, 2024 · 26 comments
Open

[Bug]: The source map is not working on Sentry #7914

cjnoname opened this issue Sep 17, 2024 · 26 comments
Assignees
Labels
bug Something isn't working urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority)

Comments

@cjnoname
Copy link

cjnoname commented Sep 17, 2024

System Info

System:
OS: macOS 15.0
CPU: (10) arm64 Apple M1 Max
Memory: 2.03 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.8.0 - ~/.nvm/versions/node/v22.8.0/bin/node
npm: 10.8.3 - ~/.nvm/versions/node/v22.8.0/bin/npm
bun: 1.1.27 - /usr/local/bin/bun
Browsers:
Chrome: 128.0.6613.138
Safari: 18.0

Details

The source maps stopped working on Sentry. After discussing with their team, we identified that the issue was caused by an invalid source map generated by Rspack.

When testing the source map with source-map-explorer or other tools, the following error appeared:

'Your source map refers to generated column 53099 on line 39, but the source only contains 53098 columns on that line. Please verify that you are using the correct source map.'

Approximately 70% of the source map files we tested are working, while 30% have failed.

Reproduce link

No response

Reproduce Steps

https://github.com/cjnoname/rspack-reproduce

npm run s

@cjnoname cjnoname added bug Something isn't working pending triage The issue/PR is currently untouched. labels Sep 17, 2024
@hardfist
Copy link
Contributor

please provide rspack version

@cjnoname
Copy link
Author

please provide rspack version

1.0.5 the latest

@cjnoname
Copy link
Author

please provide rspack version

I could send you the buggy soucemap files and mjs files via email or whatever tools but I don't want to share them with public.

@gitim
Copy link

gitim commented Sep 17, 2024

I think this is the same issue as web-infra-dev/rsbuild#3433 we found that source map stopped generated properly since 1.0.1 version (probably after #7647). @cjnoname, you can try the 1.0.0 version of rspack to identify when it was broken.

@cjnoname
Copy link
Author

I think this is the same issue as web-infra-dev/rsbuild#3433 we found that source map stopped generated properly since 1.0.1 version (probably after #7647). @cjnoname, you can try the 1.0.0 version of rspack to identify when it was broken.

Apologies, I haven't had time to test it with version 1.0.1, but I’m quite sure it was working before when I tested it.

@cjnoname
Copy link
Author

@hardfist

This is a significant issue since Sentry is the primary monitoring tool for many companies, and I hope someone can assist in looking into it.

Verifying the issue is straightforward - a single command line should work:

npx source-map-explorer index.mjs index.mjs.map

Copy link
Contributor

Hello @cjnoname, sorry we can't investigate the problem further without reproduction demo, please provide a repro demo by forking rspack-repro, or provide a minimal GitHub repository by yourself. Issues labeled by need reproduction will be closed if no activities in 14 days.

@hardfist
Copy link
Contributor

hardfist commented Sep 17, 2024

@hardfist

This is a significant issue since Sentry is the primary monitoring tool for many companies, and I hope someone can assist in looking into it.

Verifying the issue is straightforward - a single command line should work:

npx source-map-explorer index.mjs index.mjs.map

@cjnoname I can't investigate more without any reproductions, maybe you should try upgrade to 1.0.5 to see whether the sourcemap problem is solved

@cjnoname
Copy link
Author

@hardfist
This is a significant issue since Sentry is the primary monitoring tool for many companies, and I hope someone can assist in looking into it.
Verifying the issue is straightforward - a single command line should work:
npx source-map-explorer index.mjs index.mjs.map

@cjnoname I can't investigate more without any reproductions, maybe you should try upgrade to 1.0.5 to see whether the sourcemap problem is solved

https://github.com/cjnoname/rspack-reproduce

You can find the issue with a simple command: "npm run s".

I am not sure if this is the only issue causing the sourcemap to break, or if there might be other issues as well.

@yuzhva
Copy link

yuzhva commented Sep 17, 2024

maybe you should try upgrade to 1.0.5 to see whether the sourcemap problem is solved

Hey hi, guys 👋

Would like to confirm that the latest v1.0.5 has a broken source map.

We upgraded from 0.7.5 to 1.0.3 and noticed an issue with the broken source-map - there is a big % of [no source] code based on source-map-explorer package analysis.
(NOTE: you need to run the package with --no-border-checks key to process the broken source maps completely, e.g: npx source-map-explorer --no-border-checks ./dist)

So we downgraded all @rspack packages to stable v1.0.0

@hardfist hardfist added urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) and removed need reproduction pending triage The issue/PR is currently untouched. labels Sep 18, 2024
@hardfist
Copy link
Contributor

@yuzhva @cjnoname sorry for the inconvenience and reproduction, confirmed it's a bug we are gonna fix it ASAP.

@cjnoname
Copy link
Author

cjnoname commented Sep 18, 2024

@yuzhva @cjnoname sorry for the inconvenience and reproduction, confirmed it's a bug we are gonna fix it ASAP.

I’ve put together a minimal reproduction repository last night. While I haven't done something exactly like this before, it should accurately represent the issue.

https://github.com/cjnoname/rspack-reproduce

run "npm run s" can present this issue.

Not sure if it's the only issue on sourcemap or not.

@SyMind
Copy link
Member

SyMind commented Sep 18, 2024

I am currently investigating this issue.

@SyMind
Copy link
Member

SyMind commented Sep 18, 2024

@cjnoname Currently, it looks like the issue with the source map is caused by the swc minifier. Please use the Terser Webpack Plugin to handle code minification first.

If the issue persists, there may be other factors causing the source map generation error. Please provide additional repos to reproduce the problem.

@SyMind
Copy link
Member

SyMind commented Sep 18, 2024

In this repository, you can observe that the source maps generated by SWC cause errors in source-map-explorer.
https://github.com/SyMind/swc-minifier-source-map-bug

@cjnoname
Copy link
Author

In this repository, you can observe that the source maps generated by SWC cause errors in source-map-explorer. https://github.com/SyMind/swc-minifier-source-map-bug

Thank you for investigating this issue. I understand that the SWC minifier is also maintained by your team, correct?

Could you let us know if there are any plans to address this issue in the near future? We are willing to wait a few days if necessary.

We are experiencing poor performance with the Terser Webpack Plugin, which we would prefer not to revert to.

Do you have an estimated timeline for a fix?

Thanks

@SyMind
Copy link
Member

SyMind commented Sep 18, 2024

@cjnoname I'm not certain if the issue is actually caused by the SWC minifier. Could you please try using the Terser Webpack Plugin and see if the problem persists?

@SyMind
Copy link
Member

SyMind commented Sep 18, 2024

@yuzhva Please provide the a demo to reproduce the issue.

@cjnoname
Copy link
Author

@cjnoname I'm not certain if the issue is actually caused by the SWC minifier. Could you please try using the Terser Webpack Plugin and see if the problem persists?

The issue persists even after I turned off the minimizer and disabled output: module. It still occurs. You can easily check it in my repo by adjusting the rspack.config.js file.

@SyMind
Copy link
Member

SyMind commented Sep 18, 2024

@cjnoname Please don't turn off the minimizer. I've tried this before, and I found that some modules in node_modules have source map comments. This causes source-map-explorer to throw errors.

@SyMind
Copy link
Member

SyMind commented Sep 18, 2024

@cjnoname You can see the code in source-map-explorer here: https://github.com/danvk/source-map-explorer/blob/master/src/lib/explore.ts#L208

@cjnoname
Copy link
Author

@cjnoname You can see the code in source-map-explorer here: https://github.com/danvk/source-map-explorer/blob/master/src/lib/explore.ts#L208

It works, but it's running much slower than before. Could you help me report this issue to SWC?

@SyMind
Copy link
Member

SyMind commented Sep 18, 2024

@cjnoname Yes. If you can confirm that the issue is caused by the SWC minifier, I will continue to work on it.

@cjnoname
Copy link
Author

@cjnoname Yes. If you can confirm that the issue is caused by the SWC minifier, I will continue to work on it.

Yeah... Terser Webpack Plugin works fine for now. Please go ahead.

@yuzhva
Copy link

yuzhva commented Sep 18, 2024

Here is a fork with an example for source-map "investigation":
yuzhva/rspack-repro@7ad443c

I just forked the original repo https://github.com/web-infra-dev/rspack-repro and enabled the source map for rsbuild.config.ts and rspack.config.mjs configs:

Results of Source Map investigation:

For v1.0.5:

I will prepare the same ones for v.1.0.0 if I would be able to find some spare time today.

@yuzhva
Copy link

yuzhva commented Sep 18, 2024

@SyMind
cc: @cjnoname

Would like to confirm that the root cause is in swc minifiyer.

🔴 Our current configuration that does not work:

const { SwcJsMinimizerRspackPlugin } = require('@rspack/core');

optimization: {
  minimize: true,
  minimizer: [new SwcJsMinimizerRspackPlugin()],
},

🟢 There are few options that you can use to make it work:

Source Map works with one of the next configs:

  1. either disable minification:
optimization: {
  minimize: false,
},
  1. or pass empty array as minimizer key for config:
optimization: {
  minimize: true,
  minimizer: [],
},
  1. Use Terser Webpack Plugin for minimication:
const TerserPlugin = require("terser-webpack-plugin");

optimization: {
  minimize: true,
  minimizer: [new TerserPlugin()],
},

The Terser covers 100% of the source map, but it is very slow.


UPD: The 'swc-minify-webpack-plugin' - gives the same results as SwcJsMinimizerRspackPlugin with a lot of broken source-map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority)
Projects
None yet
Development

No branches or pull requests

5 participants