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 · 76 comments · Fixed by #7991, swc-project/swc#9627, #8080, web-infra-dev/rspack-sources#120 or #8138
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.

@SyMind
Copy link
Member

SyMind commented Oct 11, 2024

@cjnoname I have released the 1.0.10 version https://github.com/web-infra-dev/rspack/releases/tag/v1.0.10

@mmazzarolo
Copy link

mmazzarolo commented Oct 11, 2024

For what's worth, we added @rspack/[email protected] as a resolution (to use it in RSBuild) and production sourcemaps are still broken for us.
Can also pinpoint the issue to be starting from @rspack/[email protected]. If we use @rsbuild/[email protected] (which depends on @rspack/[email protected]) sourcemaps work just fine.

@9aoy 9aoy reopened this Oct 14, 2024
@yuzhva
Copy link

yuzhva commented Oct 14, 2024

In 1.0.10 version source maps have been restored for 27.4% for our project - it's still better than having 100% of broken source maps.

It's a bit hard to debug to understand what exactly part of the code does not receive generated source maps: the app code, .mjs modules, or something else 🤷


Will try to debug it more to understand which parts of the source maps are missing...

@SyMind
Copy link
Member

SyMind commented Oct 15, 2024

@mmazzarolo can you give me a reproduce.

@mmazzarolo
Copy link

I've been trying, but I can't produce a "minimal" reproducible example 😔. Out production codebase is pretty big and as @yuzhva mentioned it's hard to determine what's causing the issue and putting it into a minimal reproducible example. I tried using same RSBuild config and some similar npm packages for example, but with no success.
The only thing I can confirm is that our issues have been introduced in https://github.com/web-infra-dev/rspack/releases/tag/v1.0.1 (I assume it's from #7647) — if we revert to a version of rsbuild that depends on 1.0.0 everything works fine (we're basically stuck in this state since our app is otherwise unusable without working sourcemaps).

@SyMind
Copy link
Member

SyMind commented Oct 16, 2024

I will release a new version for rspack today to fix this issue.

@SyMind SyMind reopened this Oct 16, 2024
@SyMind
Copy link
Member

SyMind commented Oct 16, 2024

@mmazzarolo I've released a canary version of Rspack @rspack/[email protected]. Could you please verify if it works correctly? Thank you!

To override @rspack/core, use the following configuration:

"@rspack/core": "npm:@rspack/[email protected]"

@mmazzarolo
Copy link

mmazzarolo commented Oct 16, 2024

@SyMind thanks for looking into ti!

I assume you mean to add it as an override/resolution, right?

So adding:

  "resolutions": {
    "@rspack/core": "npm:@rspack/[email protected]"
  },

If I do that, the install step (using pnpm i) goes fine. And I see it resolved correcly in the lockfile.

But building fails:

  Rsbuild v1.0.14

error   Failed to build.
error   Unmatched version @rspack/[email protected], @rspack/[email protected], @rspack/[email protected]
    at checkVersion (/Users/matteo.mazzarolo/workspace/TTVPlatform/node_modules/@rspack/core/dist/index.js:16986:21)
    at #getInstance (/Users/matteo.mazzarolo/workspace/TTVPlatform/node_modules/@rspack/core/dist/index.js:17488:19)
    at #build (/Users/matteo.mazzarolo/workspace/TTVPlatform/node_modules/@rspack/core/dist/index.js:17412:22)
    at /Users/matteo.mazzarolo/workspace/TTVPlatform/node_modules/@rspack/core/dist/index.js:17384:18
    at done (/Users/matteo.mazzarolo/workspace/TTVPlatform/node_modules/@rspack/lite-tapable/dist/index.js:473:13)
    at AsyncSeriesHook.callAsyncStageRange (/Users/matteo.mazzarolo/workspace/TTVPlatform/node_modules/@rspack/lite-tapable/dist/index.js:480:20)
    at AsyncSeriesHook.callAsync (/Users/matteo.mazzarolo/workspace/TTVPlatform/node_modules/@rspack/lite-tapable/dist/index.js:82:21)
    at _Compiler.compile (/Users/matteo.mazzarolo/workspace/TTVPlatform/node_modules/@rspack/core/dist/index.js:17378:30)
    at /Users/matteo.mazzarolo/workspace/TTVPlatform/node_modules/@rspack/core/dist/index.js:17240:16
    at done (/Users/matteo.mazzarolo/workspace/TTVPlatform/node_modules/@rspack/lite-tapable/dist/index.js:473:13)
/Users/matteo.mazzarolo/workspace/TTVPlatform/apps/studio:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @synthesia/[email protected] build: `./scripts/build-app-with-rsbuild.sh`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.

Not sure why. Pinning specific versions of @rspack/core has worked for me before, though. Just not this one.

My setup is the following:

    "@rsbuild/core": "^1.0.14",
    "@rsbuild/plugin-react": "^1.0.4",
    "@rsbuild/plugin-svgr": "^1.0.4",
    "@rsbuild/plugin-type-check": "^1.0.1",
    "@rsdoctor/rspack-plugin": "^0.4.6",

@hmdoganjf
Copy link

I'm having the same problem with Sentry sourcemaps, and I think this canary build does not work with @rspack/cli. I keep having unmatched version error, and following the dist code I think @rspack/core thinks its on version 1.0.11, while bindings give the canary version.

[rspack-cli] Error: Unmatched version @rspack/[email protected], @rspack/[email protected], @rspack/[email protected]

Image

@mmazzarolo
Copy link

mmazzarolo commented Oct 16, 2024

@SyMind was the fix shipped with @rspack/[email protected]? Asking because i tried forcing it as a resolution to use it with rsbuild and the issue is still there for us.

@hmdoganjf
Copy link

Can confirm, issue is not resolved on 1.0.12. I guess we will have to wait until the next release.

@hardfist hardfist reopened this Oct 16, 2024
@SyMind
Copy link
Member

SyMind commented Oct 16, 2024

@mmazzarolo @hmdoganjf I released the v1.0.13 to fix this issue.

@hmdoganjf
Copy link

Yes! It seems resolved, I can see the sourcemaps on sentry. Thank you for your help.

@yuzhva
Copy link

yuzhva commented Oct 16, 2024

In 1.0.10 version source maps have been restored for 27.4% for our project - it's still better than having 100% of broken source maps.

In v1.0.13 source maps are resolved for 77.6%

NOTE: the same amount of source maps was broken in v0.7.5, so it seems to be an old issue, which is not related to the update to v.1


Here are screenshots:

v1.0.10 - 27.2% of source maps are works:
Image

v1.0.13: - 77.6% of source maps are works:
Image


TerserPlugin plugin resolves 100% of source maps:
Image


It seems that:

  • 11.2% of broken source maps are still in node_modules
  • another 11.2% of broken source maps are still in coudebase

@cjnoname
Copy link
Author

In 1.0.10 version source maps have been restored for 27.4% for our project - it's still better than having 100% of broken source maps.

In v1.0.13 source maps are resolved for 77.6%

NOTE: the same amount of source maps was broken in v0.7.5, so it seems to be an old issue, which is not related to the update to v.1

Here are screenshots:

v1.0.10 - 27.2% of source maps are works: Image

v1.0.13: - 77.6% of source maps are works: Image

TerserPlugin plugin resolves 100% of source maps: Image

It seems that:

  • 11.2% of broken source maps are still in node_modules
  • another 11.2% of broken source maps are still in coudebase

How about the RC version mate, was it 100%?

@mmazzarolo
Copy link

Thanks @SyMind 🙏 This seems to be fixing the issues so far. But we'll need a bit more time to do a complete check.

@cjnoname my understanding from @yuzhva is that the current version (the one with the fix) has a coverage of 77.6% for him. But the coverage with rspack/swc might have never been 100% (even before 1.0.1, which we suspected being the version that introduced the issue).
TerserPlugin does provide a complete coverage though... it would be interesting to understand why we can't do that with rspack/swc.

@cjnoname
Copy link
Author

Hey guys, I can confirm that the source map is inaccurate, especially as it shows errors on the wrong lines of code.

@hardfist
Copy link
Contributor

Thanks @SyMind 🙏 This seems to be fixing the issues so far. But we'll need a bit more time to do a complete check.

@cjnoname my understanding from @yuzhva is that the current version (the one with the fix) has a coverage of 77.6% for him. But the coverage with rspack/swc might have never been 100% (even before 1.0.1, which we suspected being the version that introduced the issue). TerserPlugin does provide a complete coverage though... it would be interesting to understand why we can't do that with rspack/swc.

if terserPlugin provides complete coverage and swc don't provide, then it's normally a swc minifier bug, we may need more information to investigate swc minifier problem

@SyMind
Copy link
Member

SyMind commented Oct 18, 2024

I will continue to make efforts on the SWC minifier, trying to bring it to 100%. However, this process might be quite slow.

@yuzhva
Copy link

yuzhva commented Oct 18, 2024

Hey guys, I can confirm that the source map is inaccurate, especially as it shows errors on the wrong lines of code.

@cjnoname we do have the same issue with Terser - errors are shown on the wrong lines of code when Terser is used

@SyMind
Copy link
Member

SyMind commented Oct 18, 2024

@yuzhva can you give me a reproduce repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment