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

Third party frames are not symbolicated

Open pax-k opened this issue 1 year ago • 23 comments

OS:

  • [ ] Windows
  • [x] MacOS
  • [ ] Linux

Platform:

  • [x] iOS
  • [x] Android

SDK:

  • [x] "@sentry/react-native": "5.16.0"

SDK version: 5.16.0

react-native version: 0.73.2

Are you using Expo?

  • [x] Yes
  • [ ] 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({
  enabled: ENV.APP_VARIANT !== 'development',
  dsn: ENV.SENTRY_DSN,
  debug: false,
  attachStacktrace: true,
  enableAutoSessionTracking: true,
  attachViewHierarchy: true,
  environment: ENV.APP_VARIANT,
  tracesSampleRate: 1.0,
  enableNdkScopeSync: true,
  _experiments: {
    profilesSampleRate: 1.0,
  },
  enableAppHangTracking: true,
  appHangTimeoutInterval: 5,
  enableAutoPerformanceTracing: true,
  enableTracing: true,
  enableCaptureFailedRequests: true,
  enableWatchdogTerminationTracking: true,
  sessionTrackingIntervalMillis: 10000,
  integrations: [new CaptureConsole({ levels: ['warn', 'error'] }), new HttpClient()],
  beforeBreadcrumb: (breadcrumb) => {
    if (
      ENV.APP_VARIANT === 'production' &&
      breadcrumb.category === 'console' &&
      breadcrumb.level === 'debug'
    ) {
      return null;
    }
    return breadcrumb;
  },
});

(app.config.js)

export default {
  expo: {
    name: getVariantConfigs()[APP_VARIANT].name,
    slug: 'xxx',
    owner: 'zzz',
    version: '0.1.7',
    orientation: 'portrait',
    icon: './assets/icon.png',
    userInterfaceStyle: 'light',
    scheme: 'xxx',
    jsEngine: 'hermes',
    sdkVersion: '50.0.0',
    splash: {
      image: './assets/splash.png',
      resizeMode: 'contain',
      backgroundColor: '#ffffff',
    },
    assetBundlePatterns: ['**/*'],
    ios: {
      supportsTablet: true,
      infoPlist: {
        NSFaceIDUsageDescription: 'Authentication with TouchId or FaceID',
      },
      bundleIdentifier: getVariantConfigs()[APP_VARIANT].ios.bundleIdentifier,
      buildNumber: '145',
    },
    android: {
      package: getVariantConfigs()[APP_VARIANT].android.package,
      adaptiveIcon: {
        foregroundImage: './assets/adaptive-icon.png',
        backgroundColor: '#FFFFFF',
      },
      versionCode: 145,
    },
    web: {
      favicon: './assets/favicon.png',
    },
    plugins: [
      'expo-updates',
      'expo-secure-store',
      [
        '@sentry/react-native/expo',
        {
          project: 'xxx',
          organization: 'yyy',
        },
      ],
    ],
    hooks: {},
    ...
  }

(`metro.config.js)

const { getSentryExpoConfig } = require('@sentry/react-native/metro');
const {
  createSentryMetroSerializer,
} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');
const { mergeConfig } = require('metro-config');
const customConfig = require('./metro-custom.config.js');

const config = getSentryExpoConfig(__dirname);

const { resolver } = config;

config.resolver = {
  ...resolver,
  sourceExts: [...resolver.sourceExts, 'cjs', 'mjs'],
  serializer: {
    customSerializer: createSentryMetroSerializer(),
  },
};

module.exports = mergeConfig(config, customConfig);

I have the following issue:

  • I expect to see the source code of an error in Sentry (based on uploaded sourcemaps)

Steps to reproduce: a) Run EAS Build => it should upload sourcemaps automatically. EAS Build XCode logs:

+ BUNDLE_FILE=/Users/expo/Library/Developer/Xcode/DerivedData/PrevFeatKin-aimsbvhikjjxnbexkicuzygwdefv/Build/Intermediates.noindex/ArchiveIntermediates/PrevFeatKin/BuildProductsPath/Release-iphoneos/PrevFeatKin.app/main.jsbundle
+ [[ false != true ]]
+ [[ ! -f /Users/expo/Library/Developer/Xcode/DerivedData/PrevFeatKin-aimsbvhikjjxnbexkicuzygwdefv/Build/Intermediates.noindex/ArchiveIntermediates/PrevFeatKin/BuildProductsPath/Release-iphoneos/PrevFeatKin.app/main.jsbundle ]]
Using Hermes bundle and combined 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: 40de2ff6-40ed-56a4-a641-311a063a1ee5
> Uploaded files to Sentry
> File upload complete (processing pending on server)
> Organization: xxx
> Project: zzz
> Release: None
> Dist: None
> Upload type: artifact bundle

Source Map Upload Report
  Minified Scripts
    ~/main.jsbundle (sourcemap at main.jsbundle.map, debug id 8426621a-1d1d-4ae8-a24f-1fd9763d933c)
  Source Maps
    ~/main.jsbundle.map (debug id 8426621a-1d1d-4ae8-a24f-1fd9763d933c)
+ '[' -z '' ']'
++ /Users/expo/.nvm/versions/node/v18.16.0/bin/node --print 'require('\''path'\'').dirname(require.resolve('\''@sentry/react-native/package.json'\''))'
+ SENTRY_RN_PACKAGE_PATH=/Users/expo/workingdir/build/node_modules/@sentry/react-native
+ '[' -z '' ']'
+ SENTRY_COLLECT_MODULES=/Users/expo/workingdir/build/node_modules/@sentry/react-native/scripts/collect-modules.sh
+ '[' -f /Users/expo/workingdir/build/node_modules/@sentry/react-native/scripts/collect-modules.sh ']'
+ /bin/sh /Users/expo/workingdir/build/node_modules/@sentry/react-native/scripts/collect-modules.sh
+ [[ Release = *Debug* ]]
+ [[ -z /Users/expo/Library/Developer/Xcode/DerivedData/PrevFeatKin-aimsbvhikjjxnbexkicuzygwdefv/Build/Intermediates.noindex/ArchiveIntermediates/PrevFeatKin/BuildProductsPath/Release-iphoneos ]]
+ [[ -z PrevFeatKin.app ]]
+ [[ -z /Users/expo/Library/Developer/Xcode/DerivedData/PrevFeatKin-aimsbvhikjjxnbexkicuzygwdefv/Build/Intermediates.noindex/ArchiveIntermediates/PrevFeatKin/IntermediateBuildFilesPath/PrevFeatKin.build/Release-iphoneos/PrevFeatKin.build/DerivedSources ]]
+ nodePath=node
+ [[ -n /Users/expo/.nvm/versions/node/v18.16.0/bin/node ]]
+ nodePath=/Users/expo/.nvm/versions/node/v18.16.0/bin/node
++ dirname /Users/expo/workingdir/build/node_modules/@sentry/react-native/scripts/collect-modules.sh
+ thisFilePath=/Users/expo/workingdir/build/node_modules/@sentry/react-native/scripts
+ collectModulesScript=/Users/expo/workingdir/build/node_modules/@sentry/react-native/scripts/../dist/js/tools/collectModules.js
+ destination=/Users/expo/Library/Developer/Xcode/DerivedData/PrevFeatKin-aimsbvhikjjxnbexkicuzygwdefv/Build/Intermediates.noindex/ArchiveIntermediates/PrevFeatKin/BuildProductsPath/Release-iphoneos/PrevFeatKin.app
+ modulesOutput=/Users/expo/Library/Developer/Xcode/DerivedData/PrevFeatKin-aimsbvhikjjxnbexkicuzygwdefv/Build/Intermediates.noindex/ArchiveIntermediates/PrevFeatKin/BuildProductsPath/Release-iphoneos/PrevFeatKin.app/modules.json
+ [[ -z '' ]]
+ sourceMap=/Users/expo/Library/Developer/Xcode/DerivedData/PrevFeatKin-aimsbvhikjjxnbexkicuzygwdefv/Build/Intermediates.noindex/ArchiveIntermediates/PrevFeatKin/IntermediateBuildFilesPath/PrevFeatKin.build/Release-iphoneos/PrevFeatKin.build/DerivedSources/main.jsbundle.map
+ [[ -z '' ]]
+ modulesPaths=/Users/expo/workingdir/build/ios/../node_modules
+ type /Users/expo/.nvm/versions/node/v18.16.0/bin/node
+ /Users/expo/.nvm/versions/node/v18.16.0/bin/node /Users/expo/workingdir/build/node_modules/@sentry/react-native/scripts/../dist/js/tools/collectModules.js /Users/expo/Library/Developer/Xcode/DerivedData/PrevFeatKin-aimsbvhikjjxnbexkicuzygwdefv/Build/Intermediates.noindex/ArchiveIntermediates/PrevFeatKin/IntermediateBuildFilesPath/PrevFeatKin.build/Release-iphoneos/PrevFeatKin.build/DerivedSources/main.jsbundle.map /Users/expo/Library/Developer/Xcode/DerivedData/PrevFeatKin-aimsbvhikjjxnbexkicuzygwdefv/Build/Intermediates.noindex/ArchiveIntermediates/PrevFeatKin/BuildProductsPath/Release-iphoneos/PrevFeatKin.app/modules.json /Users/expo/workingdir/build/ios/../node_modules
Sentry Logger [info]: Reading source map from /Users/expo/Library/Developer/Xcode/DerivedData/PrevFeatKin-aimsbvhikjjxnbexkicuzygwdefv/Build/Intermediates.noindex/ArchiveIntermediates/PrevFeatKin/IntermediateBuildFilesPath/PrevFeatKin.build/Release-iphoneos/PrevFeatKin.build/DerivedSources/main.jsbundle.map
Sentry Logger [info]: Saving modules to /Users/expo/Library/Developer/Xcode/DerivedData/PrevFeatKin-aimsbvhikjjxnbexkicuzygwdefv/Build/Intermediates.noindex/ArchiveIntermediates/PrevFeatKin/BuildProductsPath/Release-iphoneos/PrevFeatKin.app/modules.json
Sentry Logger [info]: Resolving modules from paths /Users/expo/workingdir/build/ios/../node_modules
Sentry Logger [info]: Modules collected and saved to: /Users/expo/Library/Developer/Xcode/DerivedData/PrevFeatKin-aimsbvhikjjxnbexkicuzygwdefv/Build/Intermediates.noindex/ArchiveIntermediates/PrevFeatKin/BuildProductsPath/Release-iphoneos/PrevFeatKin.app/modules.json

b) OR manual upload:

npx expo export
npx sentry-expo-upload-sourcemaps dist

logs:

🐕 Fetching SENTRY_PROJECT from expo config...
SENTRY_PROJECT resolved to kin-mobile from expo config.
⬆️ Uploading dist/_expo/static/js/android/index-1d0e26178998181e88bb42e95947390a.hbc bundle and sourcemap...
> Found 1 file
> Analyzing 1 sources
> Analyzing completed in 0.781s
> Rewriting sources
> Rewriting completed in 0s
> Adding source map references
> Bundling completed in 0.001s
> Bundled 1 file for upload
> Bundle ID: 123a1a0a-4f62-50b8-98eb-8a5c852fb8a4
> Optimizing completed in 0.001s
> Uploading completed in 0.236s
> Uploaded files to Sentry
> Processing completed in 0.243s
> File upload complete (processing pending on server)
> Organization: xxx
> Project: zzz
> Release: None
> Dist: None
> Upload type: artifact bundle

Source Map Upload Report
  Minified Scripts
    ~/index-1d0e26178998181e88bb42e95947390a.hbc (no sourcemap ref)
      - warning: could not determine a source map reference (Could not auto-detect referenced sourcemap for ~/index-1d0e26178998181e88bb42e95947390a.hbc)
⬆️ Uploading dist/_expo/static/js/ios/index-6d01582c3b9b7fa2a5803a5431f9fecd.hbc bundle and sourcemap...
> Found 1 file
> Analyzing 1 sources
> Analyzing completed in 0.779s
> Rewriting sources
> Rewriting completed in 0s
> Adding source map references
> Bundling completed in 0.002s
> Bundled 1 file for upload
> Bundle ID: 5cd92359-70a3-5e29-8917-25b3696199a7
> Optimizing completed in 0s
> Uploading completed in 0.208s
> Uploaded files to Sentry
> Processing completed in 0.272s
> File upload complete (processing pending on server)
> Organization: xxx
> Project: zzz
> Release: None
> Dist: None
> Upload type: artifact bundle

Source Map Upload Report
  Minified Scripts
    ~/index-6d01582c3b9b7fa2a5803a5431f9fecd.hbc (no sourcemap ref)
      - warning: could not determine a source map reference (Could not auto-detect referenced sourcemap for ~/index-6d01582c3b9b7fa2a5803a5431f9fecd.hbc)
✅ Uploaded bundles and sourcemaps to Sentry successfully.

Contents of dist/:

❯ tree dist
dist
├── _expo
│   └── static
│       └── js
│           ├── android
│           │   └── index-1d0e26178998181e88bb42e95947390a.hbc
│           └── ios
│               └── index-6d01582c3b9b7fa2a5803a5431f9fecd.hbc
├── assets
│   ├── 026491af08d90496accb275e49e4c63e
│   ├── 02bc1fa7c0313217bde2d65ccbff40c9
│   ├── 0ea69b5077e7c4696db85dbcba75b0e1
│   ├── 35ba0eaec5a4f5ed12ca16fabeae451d
│   ├── 376d6a4c7f622917c39feb23671ef71d
│   ├── 5223c8d9b0d08b82a5670fb5f71faf78
│   ├── 629a55a7e793da068dc580d184cc0e31
│   ├── 6ee4be30a6bb3c31bc333d88da8cdbb5
│   ├── 778ffc9fe8773a878e9c30a6304784de
│   ├── 7d40544b395c5949f4646f5e150fe020
│   ├── 95d6a6037f694266d9b31763e5d6f099
│   ├── a132ecc4ba5c1517ff83c0fb321bc7fc
│   ├── c79c3606a1cf168006ad3979763c7e0c
│   ├── cdd04e13d4ec83ff0cd13ec8dabdc341
│   ├── e4fe68503ab5d004deb31e43636a0a7c
│   └── f5b790e2ac193b3d41015edb3551f9b8
└── metadata.json

Actual result:

I cannot see the source code which triggered an error

Expected result:

I expect to see the source code which triggered an error

Screenshot 2024-01-23 at 15 38 08

pax-k avatar Jan 23 '24 12:01 pax-k

Hi @pax-k, thank you for the message, the logs, and the links.

I see a small issue in the metro.config.js, the sentryMetroSerializer is designed for bare React Native configurations, I removed it from your example.

const { getSentryExpoConfig } = require('@sentry/react-native/metro');
const { mergeConfig } = require('metro-config');
const customConfig = require('./metro-custom.config.js');

const config = getSentryExpoConfig(__dirname);

const { resolver } = config;

config.resolver = {
  ...resolver,
  sourceExts: [...resolver.sourceExts, 'cjs', 'mjs'],
};

module.exports = mergeConfig(config, customConfig);

Could you share what is in metro-custom.config.js, from what I can see the source maps only resolve node_modules, but your application code is missing.

For the Expo Updates (expo export), the command needs to emit the source maps:

npx expo export --dump-sourcemaps
npx sentry-expo-upload-sourcemaps dist

Are you using continuous code generation or do you maintain the native project your self? (If the latter can you share your Bundle React Native and Images build phase?)

Let us know if this helps.

krystofwoldrich avatar Jan 23 '24 16:01 krystofwoldrich

Hey @krystofwoldrich ,

Could you share what is in metro-custom.config.js, from what I can see the source maps only resolve node_modules, but your application code is missing.

Sure, this is it:

const currentDir = process.cwd();

const config = {
  resolver: {
    sourceExts: ['ts', 'tsx', 'js', 'jsx', 'json', 'cjs', 'mjs'],
    resolveRequest: (context, moduleName, platform) => {
      // provide the omitted entrypoints
      if (moduleName === 'jsonrepair') {
        return {
          filePath: `${currentDir}/node_modules/jsonrepair/lib/esm/index.js`,
          type: 'sourceFile',
        };
      }

      // fallback to the default resolver
      return context.resolveRequest(context, moduleName, platform);
    },
  },
};

module.exports = config;

For the Expo Updates (expo export), the command needs to emit the source maps

Thanks! Actually I would never export the project manually if not necessary; I provided the manual step for brevity. But if necessary, I will implement it in our CI/CD.

Are you using continuous code generation or do you maintain the native project your self? (If the latter can you share your Bundle React Native and Images build phase?)

I'm not using continuous code generation (or I don't think I'm doing it). The project is prebuilt/ejected (i have /ios and /android) and only maintain my native expo modules by upgrading their NPM deps by hand.

share your Bundle React Native and Images build phase

Can you please instruct me what do you mean exactly? I'm happy to provide anything useful.

Thanks!

pax-k avatar Jan 23 '24 20:01 pax-k

npx expo export --dump-sourcemaps
npx sentry-expo-upload-sourcemaps dist

Hey @krystofwoldrich, I have same issue with source maps, and I've been trying to run npx sentry-expo-upload-sourcemaps dist, but I constantly get SENTRY_AUTH_TOKEN environment variable must be set. error. I do have SENTRY_AUTH_TOKEN set in .env, and expo prebuild script sees that variable normally, but for some reason this package doesn't see it.

mrljsh avatar Jan 26 '24 12:01 mrljsh

@krystofwoldrich @mrljsh how are you using the sentry-expo-upload-sourcemaps command? For me, trying to run it with npx just gives a 404, it isn't on the NPM registry and I can't find specific documentation anywhere.

Sentry's React Native docs and the Expo docs both imply that it can be run with npx sentry-expo-upload-sourcemaps but don't mention it any further. What is this command?

macksal avatar Jan 27 '24 09:01 macksal

For me, npx command works but pnpx command returns 404 error.

mrljsh avatar Jan 27 '24 09:01 mrljsh

Worked it out. It's a package.json bin registered by @sentry/react-native. For some reason, npx wasn't finding it for me. (does expo install not register binaries?).

Seems to be working after yarn installing again. It's now running OK with yarn sentry-expo-upload-sourcemaps dist. Forgive my off-topic

macksal avatar Jan 27 '24 09:01 macksal

I also have the same error that @pax-k has. I think the issue here is that the release and dist variables are not set.

How can I set them? In both examples he has

> Release: None
> Dist: None

JuanRdBO avatar Jan 28 '24 02:01 JuanRdBO

Hey @krystofwoldrich, I have same issue with source maps, and I've been trying to run npx sentry-expo-upload-sourcemaps dist, but I constantly get SENTRY_AUTH_TOKEN environment variable must be set. error. I do have SENTRY_AUTH_TOKEN set in .env, and expo prebuild script sees that variable normally, but for some reason this package doesn't see it.

@mrljsh Hi, thank you for the message, the script currently doesn't read .env files, but it's a valid feature, would you mind opening a separate issue for it?

krystofwoldrich avatar Jan 30 '24 11:01 krystofwoldrich

@macksal @mrljsh The sentry-expo-upload-sourcemaps command is defined in https://github.com/getsentry/sentry-react-native/blob/798e640f0bd1b0064c2cb09775c4527f391fd7c8/package.json#L46 and only available when @sentry/react-native is installed.

krystofwoldrich avatar Jan 30 '24 11:01 krystofwoldrich

share your Bundle React Native and Images build phase

Can you please instruct me what do you mean exactly? I'm happy to provide anything useful.

It's the shell script code that you can find in Xcode -> https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/#configure-automatic-source-maps-upload

krystofwoldrich avatar Jan 30 '24 11:01 krystofwoldrich

@pax-k Have you resolved the issue?

krystofwoldrich avatar Jan 30 '24 11:01 krystofwoldrich

@JuanRdBO The release and dist are not needed, the generated Debug ID is used to link the EAS Update or Native App release to the correct source maps.

https://docs.sentry.io/platforms/react-native/sourcemaps/uploading/expo/

When uploading the source maps you will see the ID in the Sentry CLI output.

Source Map Upload Report
  Minified Scripts
    ~/main.jsbundle (sourcemap at main.jsbundle.map, debug id 8426621a-1d1d-4ae8-a24f-1fd9763d933c)
  Source Maps
    ~/main.jsbundle.map (debug id 8426621a-1d1d-4ae8-a24f-1fd9763d933c)

krystofwoldrich avatar Jan 30 '24 11:01 krystofwoldrich

@krystofwoldrich

Not fixed yet.

It's the shell script code that you can find in Xcode -> https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/#configure-automatic-source-maps-upload

node_modules/@sentry/react-native/scripts/sentry-xcode.sh:

#!/bin/bash
# Sentry Bundle React Native code and images
# PWD=ios

# print commands before executing them and stop on first error
set -x -e

# WITH_ENVIRONMENT is executed by React Native

LOCAL_NODE_BINARY=${NODE_BINARY:-node}

[ -z "$SENTRY_PROPERTIES" ] && export SENTRY_PROPERTIES=sentry.properties
[ -z "$SOURCEMAP_FILE" ] && export SOURCEMAP_FILE="$DERIVED_FILE_DIR/main.jsbundle.map"

[ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_PACKAGE_PATH=$("$LOCAL_NODE_BINARY" --print "require('path').dirname(require.resolve('@sentry/cli/package.json'))")
[ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_EXECUTABLE="${SENTRY_CLI_PACKAGE_PATH}/bin/sentry-cli"

REACT_NATIVE_XCODE=$1

[[ "$AUTO_RELEASE" != true ]] && [[ -z "$BUNDLE_COMMAND" || "$BUNDLE_COMMAND" != "ram-bundle" ]] && NO_AUTO_RELEASE="--no-auto-release"
ARGS="$NO_AUTO_RELEASE $SENTRY_CLI_EXTRA_ARGS $SENTRY_CLI_RN_XCODE_EXTRA_ARGS"

REACT_NATIVE_XCODE_WITH_SENTRY="\"$SENTRY_CLI_EXECUTABLE\" react-native xcode $ARGS \"$REACT_NATIVE_XCODE\""

if [ "$SENTRY_DISABLE_AUTO_UPLOAD" != true ]; then
  /bin/sh -c "$REACT_NATIVE_XCODE_WITH_SENTRY"
else
  echo "SENTRY_DISABLE_AUTO_UPLOAD=true, skipping sourcemaps upload"
  /bin/sh -c "$REACT_NATIVE_XCODE"
fi

[ -z "$SENTRY_COLLECT_MODULES" ] && SENTRY_RN_PACKAGE_PATH=$("$LOCAL_NODE_BINARY" --print "require('path').dirname(require.resolve('@sentry/react-native/package.json'))")
[ -z "$SENTRY_COLLECT_MODULES" ] && SENTRY_COLLECT_MODULES="${SENTRY_RN_PACKAGE_PATH}/scripts/collect-modules.sh"

if [ -f "$SENTRY_COLLECT_MODULES" ]; then
  /bin/sh "$SENTRY_COLLECT_MODULES"
fi

pax-k avatar Jan 31 '24 10:01 pax-k

As another datapoint: I'm facing the same issue when building the new version of native app, but everything is fine if I do expo update and then upload source maps manually via the CLI.

haikov avatar Feb 01 '24 10:02 haikov

@pax-k I meant the actual build phase script that you can find in Xcode.

Screenshot 2024-02-01 at 11 38 59

@pax-k Can you please describe what is the issue at the moment + the current steps? (eas build or eas updates)

krystofwoldrich avatar Feb 01 '24 10:02 krystofwoldrich

@haikov Thank you for the message.

Are you using continuous code generation? You should see the following about uploaded source maps in the Xcode build logs.

Source Map Upload Report
  Minified Scripts
    ~/main.jsbundle (sourcemap at main.jsbundle.map, debug id 8426621a-1d1d-4ae8-a24f-1fd9763d933c)
  Source Maps
    ~/main.jsbundle.map (debug id 8426621a-1d1d-4ae8-a24f-1fd9763d933c)

If you manage the Xcode project manually please check that the React Native build phase is calling sentry-xcode.sh, like shown in https://github.com/getsentry/sentry-react-native/issues/3546#issuecomment-1921024186

krystofwoldrich avatar Feb 01 '24 10:02 krystofwoldrich

I'm using eas build cloud service to build my android app and I have the same problem. But I don't see any log mentioning it's uploading source map. But I do see it in Sentry, except it's not readable.

Also, I don't know if it's related but all the tags (component, device, dist, etc.) and contexts (user, device, packages, etc.) I used to have with Expo are gone... is it related/normal?

App.js

...
import * as Sentry from "@sentry/react-native";
...

Sentry.init({
  debug: config.debug,
  dsn: config.dns,
  enabled: config.send,
  environment: config.environment,
});

function App() {
...
}

export default Sentry.wrap(App);

app.config.js

...
    plugins: [
      "expo-font",
      "expo-localization",
      "expo-secure-store",
      [
        "@sentry/react-native/expo",
        {
          url: "https://sentry.io/",
          authToken: process.env.SENTRY_AUTH_TOKEN,
          project: "my-project",
          organization: "my-org",
        },
      ],
    ],
...

metro.config.js

// 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;

newfylox avatar Feb 01 '24 19:02 newfylox

@newfylox Have you added the SENTRY_AUTH_TOKEN to your EAS Build envs?

  • https://docs.expo.dev/build-reference/variables/#using-secrets-in-environment-variables

If you do have the auth token added, but the source maps are not uploading, can you add the following envs to your app.config.js (https://docs.expo.dev/build-reference/variables/#for-use-by-your-expo-config)?

{
	"SENTRY_CLI_EXTRA_ARGS": "--force-foreground --log-level=debug"
}

krystofwoldrich avatar Feb 05 '24 14:02 krystofwoldrich

@krystofwoldrich Thanks for your help.

Before reading your comment, I did some changes last friday. I was using a secret string in Expo as explained in the link you sent since 2 or 3 years. But I decided to generate an organization token instead of a user one. Also, I manually uploaded the sourcemaps after doing a false update (to generate the dist folder). I also removed some useless settings in Sentry.init.

I can tell that only migrating from Expo to Sentry, using already existing project, does the same issue as the user who did create this issue on Github. Maybe a coincidence? But now it's working, I have most of all the tags I had when I used Expo and the contexts variables too. And now I can see the exact line in Sentry where it crashed when raising an error.

newfylox avatar Feb 05 '24 16:02 newfylox

@krystofwoldrich

here is the build phase script:

if [[ -f "$PODS_ROOT/../.xcode.env" ]]; then
  source "$PODS_ROOT/../.xcode.env"
fi
if [[ -f "$PODS_ROOT/../.xcode.env.local" ]]; then
  source "$PODS_ROOT/../.xcode.env.local"
fi

# The project root by default is one level up from the ios directory
export PROJECT_ROOT="$PROJECT_DIR"/..

if [[ "$CONFIGURATION" = *Debug* ]]; then
  export SKIP_BUNDLING=1
fi
if [[ -z "$ENTRY_FILE" ]]; then
  # Set the entry JS file using the bundler's entry resolution.
  export ENTRY_FILE="$("$NODE_BINARY" -e "require('expo/scripts/resolveAppEntry')" "$PROJECT_ROOT" ios relative | tail -n 1)"
fi

if [[ -z "$CLI_PATH" ]]; then
  # Use Expo CLI
  export CLI_PATH="$("$NODE_BINARY" --print "require.resolve('@expo/cli', { paths: [require.resolve('expo/package.json')] })")"
fi
if [[ -z "$BUNDLE_COMMAND" ]]; then
  # Default Expo CLI command for bundling
  export BUNDLE_COMMAND="export:embed"
fi

# Source .xcode.env.updates if it exists to allow
# SKIP_BUNDLING to be unset if needed
if [[ -f "$PODS_ROOT/../.xcode.env.updates" ]]; then
  source "$PODS_ROOT/../.xcode.env.updates"
fi
# Source local changes to allow overrides
# if needed
if [[ -f "$PODS_ROOT/../.xcode.env.local" ]]; then
  source "$PODS_ROOT/../.xcode.env.local"
fi

/bin/sh `"$NODE_BINARY" --print "require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'"` `"$NODE_BINARY" --print "require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'"`

Seems like this script sources the NODE_BINARY var from .xcode.env.local. Worth noting that I have to delete this file each time it reappears, because it sets NODE_BINARY to some path that doesn't exist, causing the build to fail. This started happening once I upgraded to Expo 50 and started using the new Expo + Sentry integration (but I don't know which one of these two is the cause).

pax-k avatar Feb 06 '24 08:02 pax-k

@pax-k The build phase looks correct, also your original log from the build showed the source maps uploaded correctly.

When you build the app could you bump the application version to something you haven't yet used so we can rule out that there is a collision of already uploaded source maps and the newly created ones?

krystofwoldrich avatar Feb 06 '24 13:02 krystofwoldrich

@krystofwoldrich we bump the app's version automatically, so it's safe to rule this out.

Actually the problem is this:

  • source maps of our expo app are uploaded and can be seen in Sentry
  • but source maps of our node_modules are ignored by Sentry. This is what we're interested in.

Our 3rd party dependency we're interested in has it's own .map file. Also the .map produced by yarn expo export -s contains this 3rd party .map. But for some reason, Sentry fails to process it.

Tried adding this to metro.config.js:

config.transformer = {
  ...config.transformer,
  minifierConfig: {
    ...config.transformer.minifierConfig,
    sourceMap: {
      includeSources: true,
    },
  },
};

config.serializer = {
  ...config.serializer,
  isThirdPartyModule: (module) => {
    if (module.path.includes('node_modules/our-dep/dist/main.mjs')) {
      return false;
    }
    return true;
  },
};

But seems it doesn't affect the generated .map anyway

pax-k avatar Feb 22 '24 16:02 pax-k

@pax-k Thank you for the message.

To avoid misunderstanding, do I understand correctly that only the third-party frames are not symbolicated, but application frames are? Is that the current issue?

When you try to symbolicate the minified stack trace manual using metro-symbolicate and the created source map are the third-party frames symbolicated?

https://reactnative.dev/docs/debugging-release-builds#using-metro-symbolicate

krystofwoldrich avatar Feb 23 '24 17:02 krystofwoldrich

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 Mar 15 '24 12:03 krystofwoldrich