Closed ayush-leap closed 1 week ago
Our React Native Source Maps documentation is based on react-native-xcode.sh for iOS and on BundleHermesCTask.kt for Android. If you are having issues with the manually generated artifacts check the steps of your React Native tooling using the previous links.
It's mentioned here that documentation is based on RN 0.71, we're on 0.69.9. I found below error in logs, which doesn't seem to be expected. It might be due to some changes in internal script maybe, sharing for visibility.
+ HBC_SOURCEMAP_FILE=/Users/ayush/Library/Developer/Xcode/DerivedData/LeapCosmosWallet-aieqbzeeofvilehfqxgzlgsgmnyi/Build/Products/Release-iphonesimulator/main.jsbundle.map
+ /Users/ayush/dev/leap/leap-cosmos-mobile/node_modules/@sentry/cli-darwin/bin/sentry-cli /Users/ayush/dev/leap/leap-cosmos-mobile/node_modules/react-native/scripts/compose-source-maps.js /Users/ayush/Library/Developer/Xcode/DerivedData/LeapCosmosWallet-aieqbzeeofvilehfqxgzlgsgmnyi/Build/Products/Release-iphonesimulator/main.jsbundle.map /Users/ayush/Library/Developer/Xcode/DerivedData/LeapCosmosWallet-aieqbzeeofvilehfqxgzlgsgmnyi/Build/Products/Release-iphonesimulator/main.jsbundle.map -o /Users/ayush/Library/Developer/Xcode/DerivedData/LeapCosmosWallet-aieqbzeeofvilehfqxgzlgsgmnyi/Build/Intermediates.noindex/LeapCosmosWallet.build/Release-iphonesimulator/LeapCosmosWalletLeap.build/DerivedSources/main.jsbundle.map
node:internal/fs/utils:344
throw err;
^
Error: ENOENT: no such file or directory, open '/Users/ayush/Library/Developer/Xcode/DerivedData/LeapCosmosWallet-aieqbzeeofvilehfqxgzlgsgmnyi/Build/Products/Release-iphonesimulator/main.jsbundle.map'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at Object.<anonymous> (/Users/ayush/dev/leap/leap-cosmos-mobile/node_modules/react-native/scripts/compose-source-maps.js:34:8)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/Users/ayush/Library/Developer/Xcode/DerivedData/LeapCosmosWallet-aieqbzeeofvilehfqxgzlgsgmnyi/Build/Products/Release-iphonesimulator/main.jsbundle.map'
}
+ BUNDLE_FILE=/Users/ayush/Library/Developer/Xcode/DerivedData/LeapCosmosWallet-aieqbzeeofvilehfqxgzlgsgmnyi/Build/Products/Release-iphonesimulator/LeapCosmosWalletLeap.app/main.jsbundle
+ [[ false != true ]]
+ [[ ! -f /Users/ayush/Library/Developer/Xcode/DerivedData/LeapCosmosWallet-aieqbzeeofvilehfqxgzlgsgmnyi/Build/Products/Release-iphonesimulator/LeapCosmosWalletLeap.app/main.jsbundle ]]
Using React Native Packager bundle and source map.
Processing react-native sourcemaps for Sentry upload.
> Analyzing 2 sources
> Rewriting sources
> Adding source map references
> Bundled 2 files for upload
> Bundle ID: c956a940-208d-5fd4-a9fb-35220f79ee34
> Uploaded files to Sentry
> File upload complete (processing pending on server)
> Organization: leapwallet
> Project: leap-cosmos-mobile
> Release: com.LeapCosmosWallet@0.0.1+80
> Dist: 80
> Upload type: artifact bundle
Source Map Upload Report
Scripts
~/main.jsbundle (sourcemap at main.jsbundle.map, debug id 765917f4-c73b-424e-9d96-49409eeefa63)
Source Maps
~/main.jsbundle.map (debug id 765917f4-c73b-424e-9d96-49409eeefa63)
Hi @ayush-leap, thank you for the message and the exceptional amount of details, this makes solving the issue much easier.
Please, remove export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"
from the iOS build phase. When using sentry-xcode.sh
the extra packagers args are not needed anymore, SOURCEMAP_FILE
is set by the script.
If this was not helpful feel free to comment here and we can reopen the issue.
hi @krystofwoldrich,
thank you for suggesting a fix. After removing EXTRA_PACKAGER_ARGS
export from Bundle build phase, the error I mentioned here is gone from the build logs.
although, it still didn't capture the correct stack trace for some reason. I did cleaned build folder & xcode derived data before making a new release build. also updated the release & dist. any other fix you could think of?
i'm simply triggering error like below:
try {
throw new Error("Buy button error");
} catch (err) {
captureException(err);
}
I also had following questions:
../node_modules/@sentry/cli/bin/sentry-cli react-native xcode
line? It's not mentioned in the setup here but was added by @sentry/wizard and it seems to upload some native symbols. Can we remove it's explicit call now that I can see it's already added in sentry-xcode.sh
?withSentryConfig
is released in 5.17.0 but none of the documentations mentions it's usage. is it not recommended to use or just that its yet to be documented? I've currently explicitly added createSentryMetroSerializer
. (update: it got added now in documentation now I think here.)should i try this - https://github.com/getsentry/sentry-react-native/issues/3751#issuecomment-2077300372 ?
update: i tried removing EXTRA_PACKAGER_ARGS
& adding SOURCEMAP_FILE
, didn't work again :/
```sh export NODE_OPTIONS=--max-old-space-size=8192 export SENTRY_PROPERTIES=sentry-leap-release.properties export SOURCEMAP_FILE="$DERIVED_FILE_DIR/main.jsbundle.map" set -e WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh" ../node_modules/@sentry/cli/bin/sentry-cli react-native xcode REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh" SENTRY_XCODE="../node_modules/@sentry/react-native/scripts/sentry-xcode.sh" BUNDLE_REACT_NATIVE="/bin/sh $SENTRY_XCODE $REACT_NATIVE_XCODE" # RN 0.69+ /bin/sh -c "$WITH_ENVIRONMENT \"$BUNDLE_REACT_NATIVE\"" # send runtime JavaScript dependencies in events for React Native apps. you can also set SENTRY_COLLECT_MODULES to be true for the same. /bin/sh ../node_modules/@sentry/react-native/scripts/collect-modules.sh ```
hey @krystofwoldrich, sorry to bump this again but we're still blocked here. possible to suggest a fix or help in finding the root cause?
fyi, hermes_debug_info
is showing up as false apparently in the issue. this should be true if we're using hermes & getting correct stack traces?
update: learned about what hermes_debug_info
is from the tests written here - https://github.com/getsentry/sentry-react-native/commit/5fefdf7ccade18e5ac77ef152aa533e60d6d5b81#diff-98c7ed2f11166b7b6a950257ce0c2374f7224dc8ec65a8d20eecd666b893a67f
Update: we updated our scripts referencing it from https://github.com/getsentry/sentry-react-native/issues/3583#issuecomment-1943805598 and it's now working as expected for us.
```sh export NODE_OPTIONS="--max-old-space-size=8192" export SENTRY_PROPERTIES=sentry-leap-release.properties export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map" set -e WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh" REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh" /bin/sh -c "$WITH_ENVIRONMENT \"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\"" # send runtime JavaScript dependencies in events for React Native apps /bin/sh ../node_modules/@sentry/react-native/scripts/collect-modules.sh ```
```sh export NODE_OPTIONS=--max-old-space-size=8192 export SENTRY_PROPERTIES=sentry-leap-release.properties [[ $SENTRY_INCLUDE_NATIVE_SOURCES == "true" ]] && INCLUDE_SOURCES_FLAG="--include-sources" || INCLUDE_SOURCES_FLAG="" SENTRY_CLI="../node_modules/@sentry/cli/bin/sentry-cli" $SENTRY_CLI debug-files upload --force-foreground "$INCLUDE_SOURCES_FLAG" "$DWARF_DSYM_FOLDER_PATH" ```
closing as we were able to get correct stack traces now. we will try to upgrade to sentry scripts mentioned in manual setup once we upgrade RN since these scripts are based on >v0.71.
OS:
Platform:
SDK:
@sentry/react-native
(>= 1.0.0)react-native-sentry
(<= 0.43.2)SDK version: 5.22.2
react-native
version: 0.69.9Are you using Expo?
Are you using sentry.io or on-premise?
If you are using sentry.io, please post a link to your issue so we can take a look:
[Link to issue]
Configuration:
(
@sentry/react-native
)I have the following issue:
We're trying to upgrade to sentry 4.x to 5.x. I've followed migration guide & manual setup for the same. We're facing an issue with stack traces on iOS. For Android, we're getting exact line where error occurred but on iOS, it shows a weird global file.
Android Stack Trace
iOS Stack Trace
xcode.env
``` export NODE_BINARY=$(command -v node) export SENTRY_CLI_EXTRA_ARGS="--force-foreground" export SENTRY_INCLUDE_NATIVE_SOURCES=true # Upload native iOS sources ```
Bundle React Native code and images
```sh export NODE_OPTIONS=--max-old-space-size=8192 export SENTRY_PROPERTIES=sentry-leap-release.properties export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map" set -e WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh" ../node_modules/@sentry/cli/bin/sentry-cli react-native xcode REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh" SENTRY_XCODE="../node_modules/@sentry/react-native/scripts/sentry-xcode.sh" BUNDLE_REACT_NATIVE="/bin/sh $SENTRY_XCODE $REACT_NATIVE_XCODE" # RN 0.69+ /bin/sh -c "$WITH_ENVIRONMENT \"$BUNDLE_REACT_NATIVE\"" # send runtime JavaScript dependencies in events for React Native apps. you can also set SENTRY_COLLECT_MODULES to be true for the same. /bin/sh ../node_modules/@sentry/react-native/scripts/collect-modules.sh ```
Upload Debug Symbols to Sentry
```sh export NODE_OPTIONS=--max-old-space-size=8192 export SENTRY_PROPERTIES=sentry-leap-release.properties /bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh ```
`metro.config.js`
```js /** * Metro configuration for React Native * https://github.com/facebook/react-native * * @format */ const { getDefaultConfig, mergeConfig } = require("metro-config"); const { createSentryMetroSerializer } = require("@sentry/react-native/dist/js/tools/sentryMetroSerializer"); module.exports = (async () => { const { resolver: { sourceExts, assetExts } } = await getDefaultConfig(); const config = { transformer: { experimentalImportSupport: false, inlineRequires: true, babelTransformerPath: require.resolve("react-native-svg-transformer") }, resolver: { assetExts: assetExts.filter((ext) => ext !== "svg"), sourceExts: [...sourceExts, "svg", "jsx", "js", "ts", "tsx", "cjs", "mjs"], extraNodeModules: require("node-libs-react-native") }, serializer: { // Sentry Metro Serializer which allows you to automatically generate Debug IDs for your applications' bundles. This is crucial for making source maps work properly with Sentry // Sentry Metro Serializer can't add Debug ID to the Hermes Composed Source Maps. // refer - https://docs.sentry.io/platforms/react-native/manual-setup/metro/ customSerializer: createSentryMetroSerializer() } }; return config; })(); ```
Source Map Artifacts for iOS
Source Map Artifacts for Android
Steps to reproduce:
Actual result:
[Actual result]
Expected result:
The iOS config seems correct as per documentation. Ideally, error on iOS should also point to the correct source on Sentry similar to Android.