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

Unsymbolicated sentry stack traces

Open jayshah123 opened this issue 1 year ago • 11 comments

OS:

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

Platform:

  • [x] iOS
  • [X] Android

SDK:

  • [X] @sentry/react-native (>= 1.0.0)
  • [ ] react-native-sentry (<= 0.43.2)

SDK version: @sentry/[email protected]

react-native version: 0.73.9

Are you using Expo?

  • [x] Yes - but in Bare workflow.
  • [ ] No

Are you using sentry.io or on-premise?

  • [x] sentry.io (SaaS)
  • [ ] 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)

  Sentry.init({
    dsn: SENTRY_DSN,
    environment: ENVIRONMENT,
    release: `${appJson.version}-${appJson.jsVersion}`,
    dist: `${appJson.versionCode}`,
    beforeSend: sentryFilter,
    enableTracing: false,
    attachStacktrace: true,
    enableWatchdogTerminationTracking: true,
    enableAutoPerformanceTracing: false,
  });

In our metro.config.js, we use @expo/metro-config as a starting point like below:

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */
const { getDefaultConfig } = require('@expo/metro-config');

const path = require('path');

async function getConfig(appDir) {
  const config = await getDefaultConfig(__dirname);
  // setup watch folders
  config.watchFolders = [path.resolve(appDir, 'node_modules')];
  // setup transformer
  config.transformer = {
    ...config.transformer,
    babelTransformerPath: require.resolve('react-native-svg-transformer/expo'),
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: true,
        inlineRequires: true,
      },
    }),
  };

  // setup resolver source extensions
  const originalSourceExts = config.resolver.sourceExts;
  let newSourceExts = process.env.RN_SRC_EXT
    ? process.env.RN_SRC_EXT.split(',').concat(originalSourceExts)
    : originalSourceExts;
  config.resolver.sourceExts = [...newSourceExts, 'svg', 'cjs', 'mjs'];

  // setup resolver asset extensions
  const origianlAssetExts = config.resolver.assetExts;
  config.resolver.assetExts = [
    ...origianlAssetExts.filter((ext) => ext !== 'svg'),
    'css',
    'scss',
  ];

  return config;
}

module.exports = getConfig(__dirname);

Upload steps for iOS (after codepush release-react):

                export SENTRY_PROPERTIES=./ios/sentry.properties
                npx react-native bundle --dev false --platform ios --entry-file index.js --bundle-output main.jsbundle --sourcemap-output main.jsbundle.map
                node_modules/@sentry/cli/bin/sentry-cli releases files $VERSION-$JSVERSION upload-sourcemaps --strip-prefix . --rewrite main.jsbundle main.jsbundle.map --dist $VERSIONCODE

Upload steps for Android (after codepush release-react):

                export SENTRY_PROPERTIES=./ios/sentry.properties
                npx react-native bundle --dev false --platform android --entry-file index.js --bundle-output index.android.bundle --sourcemap-output index.android.bundle.map
                node_modules/@sentry/cli/bin/sentry-cli releases files $VERSION-$JSVERSION upload-sourcemaps --strip-prefix . --rewrite index.android.bundle index.android.bundle.map --dist $VERSIONCODE

I have the following issue:

[Description]

  1. I have correct debugId appended in js bundle during release and same source/sourcemap is found in sentry.io.
  2. I don't see any "debugId" field in index.android.bundle.map json file.
  3. Currently # debugId comment in minified code bundle seems to be coming from: node_modules/@expo/metro-config/build/serializer/fork/baseJSBundle.js

Steps to reproduce:

  • Fire an error from android app via captureException

Actual result:

Unsymbolicated stack trace

Expected result:

Symbolicated stack trace.

jayshah123 avatar Sep 25 '24 11:09 jayshah123

Hi and thank you for opening this issue! Could you please share the commands you use to build the native app (both for iOS and Android)?

lucas-zimerman avatar Sep 25 '24 19:09 lucas-zimerman

The android native release happens through fastlane:

bundle exec fastlane android release_playstore
# upload sentry sourcemaps
export SENTRY_PROPERTIES=./android/sentry.properties
 npx react-native bundle --dev false --platform android --entry-file index.js --bundle-output index.android.bundle --sourcemap-output index.android.bundle.map
node_modules/@sentry/cli/bin/sentry-cli releases files $VERSION-$JSVERSION upload-sourcemaps --strip-prefix . --rewrite index.android.bundle index.android.bundle.map --dist $VERSIONCODE

Here are the contents of lane:

    desc "Build and upload the app to playstore for production release"
    lane :release_playstore do
        # Upload Android App Bundle to PlayStore
        upload_to_play_store(
            skip_upload_apk: true,
            skip_upload_metadata: true,
            skip_upload_changelogs: true,
            skip_upload_images: true,
            skip_upload_screenshots: true,
            aab: './android/app/build/outputs/bundle/release/app-release.aab',
            rollout: '0.1',
        )
    end

iOS native release also happens through fastlane

bundle exec fastlane ios build_appstore
bundle exec fastlane ios release_appstore
# upload sentry stuff
export SENTRY_PROPERTIES=./ios/sentry.properties
npx react-native bundle --dev false --platform ios --entry-file index.js --bundle-output main.jsbundle --sourcemap-output main.jsbundle.map
node_modules/@sentry/cli/bin/sentry-cli releases files $VERSION-$JSVERSION upload-sourcemaps --strip-prefix . --rewrite main.jsbundle main.jsbundle.map --dist $VERSIONCODE
bundle exec fastlane upload_debug_symbols_sentry_ios

Contents of fastlane:

  private_lane :publish_appstore do
    api_key = app_store_connect_api_key(
      key_id: ENV['APP_STORE_KEY_ID'],
      issuer_id: ENV['APP_STORE_ISSUER_ID'],
      key_filepath: ENV['APP_STORE_KEY_FILEPATH'],
      duration: 1200,
      in_house: false
    )

    upload_to_app_store(
      app_version: ENV['VERSION'],
      app_identifier: APP_ID,
      api_key: api_key,
      ipa: IPA_PATH,
      submit_for_review: true,
      automatic_release: false,
      skip_metadata: false,
      skip_screenshots: true,
      force: true,
      run_precheck_before_submit: false,
      # verify_only: true,
      submission_information: {
        add_id_info_uses_idfa: false
      },
      release_notes: {
        "default": 'Bug Fixes and Improvements',
        "en-US": 'Bug Fixes and Improvements'
      },
      phased_release: true
    )
  end

jayshah123 avatar Sep 26 '24 01:09 jayshah123

Thanks @jayshah123 for the detailled response, we'll investigate and follow up here.

kahest avatar Sep 26 '24 08:09 kahest

Thanks @kahest . There is one more issue around: App Hanging - "Sentry has identified the following problems for you to fix: A required debug information file was missing". Should I raise a separate issue? Or provide the issue link in this same thread?

jayshah123 avatar Sep 26 '24 08:09 jayshah123

@jayshah123 a link would be appreciated. We can keep it in this current issue until we know if it's a separate one

kahest avatar Sep 26 '24 09:09 kahest

Link to the second issue here

jayshah123 avatar Sep 26 '24 09:09 jayshah123

Let us know if something can be done here, we are trying to investigate this issue and missing symbolication makes it harder.

jayshah123 avatar Oct 07 '24 14:10 jayshah123

Hi, thank you for the message, we are in process of updation our CodePush documentation (https://github.com/getsentry/sentry-docs/pull/11550/files).

I see that you are missing the Sentry config in your Metro configuration.

  • https://docs.sentry.io/platforms/react-native/manual-setup/metro/#use-sentry-metro-serializer

The missing Sentry Config will cause that the generated Debug IDs are not used due to missing Debug ID polyfill.


The links you shared are containing native iOS crashes. To symbolicate those you need to make sure native Debug Files are uploaded. You can do that automatically during the Xcode build by using https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/#configure-automatic-debug-symbols-upload

krystofwoldrich avatar Oct 11 '24 18:10 krystofwoldrich

Checking the same, and will report if face any issues.

jayshah123 avatar Oct 14 '24 05:10 jayshah123

@krystofwoldrich

  1. For part 1, I see you referred to https://docs.sentry.io/platforms/react-native/manual-setup/metro/#use-sentry-metro-serializer. I wonder if these steps will work if my codepush bundle is a hermes bytecode bundle. Also hermes docs at https://docs.sentry.io/platforms/react-native/sourcemaps/uploading/hermes/ -> only show an example of "@react-native/metro-config" as a starting point, not '@expo/metro-config as a starting point.

  2. For part 2(ios debug symbols upload), I see we have existing upload of ios debug symbols through fastlane - via sentry_upload_dif. I noticed also see there is another way - sentry_debug_files_upload fastlane action available in the docs which we don't use at the moment. Are these equivalent to https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/#configure-automatic-debug-symbols-upload ? Which one do you recommend for react native in general for simplicity?

jayshah123 avatar Oct 23 '24 07:10 jayshah123

https://docs.sentry.io/platforms/react-native/sourcemaps/uploading/hermes/ -> only show an example of "@react-native/metro-config" as a starting point, not '@expo/metro-config as a starting point.

Yes, that's correct because this guide only applies to Base RN with Hermes, for Hermes with Expo use https://docs.sentry.io/platforms/react-native/sourcemaps/uploading/expo-advanced/ and https://docs.sentry.io/platforms/react-native/sourcemaps/uploading/expo/

I see we have existing upload of ios debug symbols through fastlane - via sentry_upload_dif. I noticed also see there is another way - sentry_debug_files_upload fastlane action available in the docs which we don't use at the moment. Are these equivalent to https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/#configure-automatic-debug-symbols-upload ?

Yes, upload_diff, debug_file_upload and the https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/#configure-automatic-debug-symbols-upload upload the same native debug symbols.

The simplest way for native releases is to use the upload in build phases, so it happens right away during the build.

For Codepush you can follow this updated guide https://docs.sentry.io/platforms/react-native/sourcemaps/uploading/codepush/

krystofwoldrich avatar Oct 23 '24 10:10 krystofwoldrich

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

getsantry[bot] avatar Nov 14 '24 08:11 getsantry[bot]

Closing this due to inactivity. If this is still an issue feel free to comment here or open a new issue if the context changed.

krystofwoldrich avatar Nov 21 '24 11:11 krystofwoldrich