sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

getDefaultConfig from expo/metro-config compromise the sourceMappingURL and it has a wrong hash when exported for web platform

Open claudioviola opened this issue 1 year ago • 10 comments

OS:

  • [ ] Windows
  • [ X] MacOS
  • [ ] Linux

Platform:

  • [ ] iOS
  • [ ] Android
"@sentry/react-native": "^5.17.0",
"expo": "^50.0.3",
"react-native": "0.73.2",
"react-native-web": "~0.19.6",
"@expo/metro-runtime": "~3.1.2",
"react": "18.2.0",
"react-dom": "18.2.0",

Are you using Expo?

  • [X ] Yes
  • [ ] No

This is the configuration of my metro.config.js placed in the root folder project

// This replaces `const { getDefaultConfig } = require('expo/metro-config');`
const { getSentryExpoConfig } = require('@sentry/react-native/metro');

// This replaces `const config = getDefaultConfig(__dirname);`
const config = getSentryExpoConfig(__dirname);

module.exports = config;

I have the following issue:

Steps to reproduce:

  • Build the web project by running this command npx expo export -p web --dump-sourcemap
  • check the dist folder

2 files are created AppEntry-9c58c4463ca3cfc79b6525f9cc37e942.js AppEntry-9c58c4463ca3cfc79b6525f9cc37e942.js.map

Actual result: Opening the first file for checking if the sourceMappingURL is correct Actually the sourceMappingURL is wrong and it contains a different hash for the Javascript bundled file //# sourceMappingURL=/_expo/static/js/web/AppEntry-c20e66115809b9d51b0088b809c85f32.js.map

Expected result:

Opening the first file for checking if the sourceMappingURL is correct the sourceMappingURL should contains the correct hash and it should points to the correct file //# sourceMappingURL=/_expo/static/js/web/AppEntry-9c58c4463ca3cfc79b6525f9cc37e942.js.map

if using in the metro.config.js const { getDefaultConfig } = require('expo/metro-config'); the issue disappears and the sourceMappingURL contains the correct file

claudioviola avatar Mar 06 '24 14:03 claudioviola

Hi @claudioviola, thank you for the message, I was able to reproduce it in our sample app, we will investigate it.

krystofwoldrich avatar Mar 07 '24 13:03 krystofwoldrich

Hey Krystof,

Support received a request in Zendesk from a user with the same issue. Do you have an update for this problem?

Link to Zendesk ticket

Fwang36 avatar Mar 28 '24 18:03 Fwang36

Hi @Fwang36, no updates yet, I'll keep you posted here.

krystofwoldrich avatar Apr 02 '24 08:04 krystofwoldrich

@krystofwoldrich is it resolved in v5.22.0?

amir-dropit avatar May 01 '24 11:05 amir-dropit

@amir-dropit No, 5.22.0 doesn't fix this particular issue.

krystofwoldrich avatar May 02 '24 14:05 krystofwoldrich

How is this not fixed yet?

amir-dropit avatar May 22 '24 08:05 amir-dropit

@krystofwoldrich can you please update on the manner? our source maps were not uploaded for 3 weeks because of this bug

YishaiGr avatar May 22 '24 10:05 YishaiGr

Hi, I'm sorry to hear that, I've opened a PR fixing this today.

  • https://github.com/expo/expo/pull/29054

I'll also post here a workaround which you can use until the fix is released.

krystofwoldrich avatar May 22 '24 16:05 krystofwoldrich

Thanks a lot! 🙏

YishaiGr avatar May 22 '24 17:05 YishaiGr

Until the fix is released, you can apply the changes from the fix PR using https://www.npmjs.com/package/patch-package

krystofwoldrich avatar May 24 '24 08:05 krystofwoldrich