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

Issue with source maps and missing artifacts #1350

Closed
darrylyoung opened this issue Feb 17, 2021 · 24 comments
Closed

Issue with source maps and missing artifacts #1350

darrylyoung opened this issue Feb 17, 2021 · 24 comments
Labels
Expo Issues related to Sentry React Native Expo support Platform: Cocoa

Comments

@darrylyoung
Copy link

Environment

How do you use Sentry?

  • Sentry SaaS (sentry.io)

Which SDK and version?

  • sentry-expo: 3.0.4
  • @sentry/react-native: 2.2.0

Steps to Reproduce

  1. Run my app (either via yarn ios or from within Xcode) – let's say version 0.0.35, build 76
  2. See a new release called 0.0.35 (76) in the Sentry project
  3. Check the release and see that there are 0 artifacts

Expected Result

Artifacts would be available.

Actual Result

There are 0 artifacts in the release.

Setup information

I started my project as an Expo managed app and eventually ejected to the bare workflow.

Everything was working as expected (source maps and artifacts were available) while on @sentry/react-native version 1.9.0 but things broke when I upgraded to 2.1.0 and they haven't been right since, regardless of what I've tried. Looking through the Source Maps section in Sentry, I last see a release with artifacts just before I did the 1.9.0 -> 2.1.0 upgrade but none since. Looking back at my changes then, I know I did something wrong – I started using:

import * as Sentry from '@sentry/react-native' instead of import { Native as Sentry } from 'sentry-expo'

Since then, I've resorted to using import { Native as Sentry } from 'sentry-expo' again after trying to debug this with somebody from Expo – I was told that I didn't need to use sentry-expo as well as @sentry/react-native but that it'd give some extra features if I did.

Here's some setup information:

sentryConfig.ts

import { Platform } from 'react-native'
import { Native as Sentry } from 'sentry-expo'

const SENTRY_DSN_IOS = 'xxx'
const SENTRY_DSN_ANDROID = 'xxx'

export const sentryConfig: Sentry.ReactNativeOptions = {
  dsn: Platform.OS === 'ios' ? SENTRY_DSN_IOS : SENTRY_DSN_ANDROID,
  enableAutoSessionTracking: true,
  debug: __DEV__ ? true : false,
  environment: __DEV__ ? 'development' : 'production',
}

App.tsx

import { Native as Sentry } from 'sentry-expo'

Sentry.init(sentryConfig)

// Sentry.captureException(error)

sentry.properties

defaults.url=https://sentry.io/
defaults.org=xxx
defaults.project=xxx
auth.token=xxx
cli.executable=node_modules/@sentry/cli/bin/sentry-cli

Xcode – Bundle React Native code and images

export NODE_BINARY=node
export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"
export SENTRY_PROPERTIES=sentry.properties
../node_modules/@sentry/cli/bin/sentry-cli react-native xcode ../node_modules/react-native/scripts/react-native-xcode.sh
../node_modules/expo-constants/scripts/get-app-config-ios.sh
../node_modules/expo-updates/scripts/create-manifest-ios.sh

Xcode – Upload Debug Symbols to Sentry

export SENTRY_PROPERTIES=sentry.properties
../node_modules/@sentry/cli/bin/sentry-cli upload-dsym

Am I missing a manual step here or is there maybe an issue with my setup? I thought that when running/building a new version/build, a new Sentry release would automatically be created and everything would be handled. Here's a screenshot of the Tags in a recent issue (from a release that has 0 artifacts):

Screenshot 2021-02-17 at 14 04 27

I can see that dist is clearly taken from my build number and release is a combination of the version and the build numbers. This is clearly done automatically as I don't set that explicitly anywhere.

The only way I've been able to create a new release and get artifacts/source maps is if I run expo publish manually. When doing this, I get a new release created but it has a name like 0.0.35-r.-DrbHnWJw and no issues seem to show up under that release. That release, however, does have artifacts, e.g.

Screenshot 2021-02-17 at 14 09 55

whereas the automatically-created releases don't:

Screenshot 2021-02-17 at 14 09 42

Apologies for the length of this issue but I've been stuck with this for a while now and I wanted to give as much context as possible, hoping that it's simply a setup issue on my side. Thanks in advance! Have a a nice day.

@jennmueng
Copy link
Member

What pops out to me as unusual is 0.0.35 (76) should not be automatically generated by us as this does not match our release name scheme of {app_identifier}@{version}+{dist}: as you can see here. So I'm not sure where this is coming from.

Also, given that it's what's being set inside the event as well, means this value is being set during runtime somewhere as well, maybe auto-set by sentry-expo?

The team over at sentry-expo would probably know more about this than I do, so cc @cruzach.

@cruzach
Copy link
Contributor

cruzach commented Feb 19, 2021

In sentry-expo, we default to Sentry's default (because we want all the errors for build-time sourcemaps to be mapped correctly 😄 ), as you can see here:

nativeOptions.release = `${Application.applicationId}@${Application.nativeApplicationVersion}+${Application.nativeBuildVersion}`;

So maybe you are passing in a release somewhere to your sentry initialization? Or is there an environment variable that is maybe overwriting the default (this is probably more relevant for the actual artifacts that are being uploaded, since env vars in react native apps aren't really a thing)

Is there anything in the xcode build logs that indicate those build scripts for uploading sourcemaps are failing?

@jennmueng
Copy link
Member

Now that I looked at this a second time with fresh eyes, I'm reminded that Sentry dashboard creates a new release for events with release names that don't match any existing ones. So that's probably what you're seeing with the empty releases, so I would look at whatever is setting that value during runtime.

@darrylyoung
Copy link
Author

Hi, guys. Thanks for looking into this for me – it's very much appreciated!

So maybe you are passing in a release somewhere to your sentry initialization?

I'm not explicitly passing release anywhere as far as I can see, nor do I remember ever doing so. My Sentry config is shown above.

Or is there an environment variable that is maybe overwriting the default

As with the previous point, I haven't explicitly set anything like that so unless a version of sentry-expo or @sentry/react-native did that, I can't see this being the issue.

Does my overall setup look correct? Also, do you have any specific places where you suggest I could look for anything else? I've covered as much as I can in the original post above but if there's anything else then I'd be happy to send it as well.

Thanks again, guys. Have a great day and weekend ahead.

@darrylyoung
Copy link
Author

Could it maybe be related to how I'm updating builds? Right now, let's say I'm on version 0.0.35 with build number 81 and I want to increment my build number but keep the same version, I'd do the following:

  1. Increment buildNumber in app.json
  2. Open the project in Xcode and bump Build in my project target
  3. Run the app locally and/or create an Archive and upload to App Store Connect for TestFlight, etc.

Whether the last step is running locally or building an Archive for upload, a new Release will be created in Sentry. In the case of this example, it'd be 0.0.35 (82).

app.json

{
  "name": "xxx",
  "displayName": "xxx",
  "expo": {
    "name": "xxx",
    "slug": "xxx",
    "version": "0.0.35",
    "sdkVersion": "40.0.0",
    "description": "xxx",
    "privacy": "unlisted",
    "platforms": ["ios", "android"],
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "scheme": "xxx",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#f9f9f9"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "buildNumber": "82",
      "bundleIdentifier": "xxx",
      "supportsTablet": false,
      "usesAppleSignIn": true,
      "infoPlist": {
        "LSApplicationQueriesSchemes": ["instagram", "twitter", "fb"]
      },
      "config": {
        "usesNonExemptEncryption": false,
        "googleSignIn": {
          "reservedClientId": "xxx"
        }
      }
    },
    "hooks": {
      "postPublish": [
        {
          "file": "sentry-expo/upload-sourcemaps",
          "config": {
            "organization": "xxx",
            "project": "xxx-ios",
            "authToken": "xxx"
          }
        }
      ]
    },
    "android": {
      "package": "xxx"
    }
  }
}

Xcode – Increment Build
Screenshot 2021-02-20 at 09 50 12

@cruzach
Copy link
Contributor

cruzach commented Feb 20, 2021

Just reproduced this on a blank-ish bare workflow app @darrylyoung - after building for release in Xcode (and seeing that the "Upload sourcemaps" shell script was run: no artifacts for that release in Sentry dashboard- but only on iOS (Android sourcemaps were uploaded perfectly fine during ./gradlew assembleRelease)

Will update here if I figure out what's going on here

@cruzach
Copy link
Contributor

cruzach commented Feb 20, 2021

Actually, looks like the issue I'm running into is #888

@jennmueng
Copy link
Member

Ok I've successfully reproduced it as well, if you add the flag --force-foreground to the build script in Xcode it seems to work.

So try replacing the "Bundle React Native code and images" build script with this, and see if it works? @darrylyoung @cruzach

export NODE_BINARY=node
export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"
export SENTRY_PROPERTIES=sentry.properties
export SENTRY_LOG_LEVEL="info"

# If you are using RN 0.46+
../node_modules/@sentry/cli/bin/sentry-cli react-native xcode --force-foreground

I'll be raising this issue to others internally I don't know why it does this.

@darrylyoung
Copy link
Author

darrylyoung commented Feb 24, 2021

Hi, @jennmueng. Thanks for the suggestion. I just tried that and I can see 2 artifacts in the new release. There have been 0 artifacts in previous releases so this clearly helped.

For context, I used the following and the only change was the addition of --force-foreground.

export NODE_BINARY=node
export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"
export SENTRY_PROPERTIES=sentry.properties
../node_modules/@sentry/cli/bin/sentry-cli react-native xcode --force-foreground ../node_modules/react-native/scripts/react-native-xcode.sh
../node_modules/expo-constants/scripts/get-app-config-ios.sh
../node_modules/expo-updates/scripts/create-manifest-ios.sh

Screenshot 2021-02-24 at 16 35 06

Thanks to both of you for your help so far with this.

Update: I just saw an issue for that latest release (the one with 2 artifacts) and at the top of the issue I see:

There was 1 error encountered while processing this event

Source code was not found

Url | /var/mobile/Containers/Data/Application/xxx/Library/Application Support/.expo-internal/bundle-xxx

@jennmueng
Copy link
Member

jennmueng commented Feb 24, 2021

@darrylyoung That error at the top looks like the source map filename was not mapped correctly, it should be replaced to app:///main.jsbundle by sentry-expo: https://github.com/expo/sentry-expo/blob/86b93c845fa66f0fc20e16b175793058e6a861e1/src/sentry.ts#L52

Edit: Oh I looked at your initial issue—if you're still using expo you should call not call the init from Native but use the normal one from * as Sentry from "sentry-expo"

@darrylyoung
Copy link
Author

darrylyoung commented Feb 25, 2021

Hi again, @jennmueng. Thanks for the suggestion. I've just made that change and I still have that same issue.

There was 1 error encountered while processing this event

Source code was not found

Url | /var/mobile/Containers/Data/Application/xxx/Library/Application Support/.expo-internal/bundle-xxx

For context, here's my setup after your suggestion:

sentry.config

import { Platform } from 'react-native'

const SENTRY_DSN_IOS = 'xxx'
const SENTRY_DSN_ANDROID = 'xxx'

export const sentryConfig = {
  dsn: Platform.OS === 'ios' ? SENTRY_DSN_IOS : SENTRY_DSN_ANDROID,
  enableInExpoDevelopment: true,
  enableAutoSessionTracking: true,
  debug: __DEV__ ? true : false,
  environment: __DEV__ ? 'development' : 'production',
}

App.tsx

import * as Sentry from 'sentry-expo'

Sentry.init(sentryConfig)

// Sentry.Native.captureException(error)

package.json

"@sentry/react-native": "^2.2.1",
"sentry-expo": "^3.0.4",

I'm also seeing the following in the issue, in case that helps:

Screenshot 2021-02-25 at 10 07 50

Update

Actually, I have two new issues in this new release and one of them has no messages/warnings about source code not being found while the other does. The one with the source code not found message looks like this:

Screenshot 2021-02-25 at 14 05 37

I've since had another issue show up and it came at the exact same time as another issue which looked like the one above. That is, it seems like issues come through normally but also come with an issue that's somehow related but has no source maps, etc.

@RishabhKarnad
Copy link

I'm facing this issue too with SDK 1.9.0 as well as 2.1.0. My setup is more similar to the one in #888 though.

Unfortunately, using --force-foreground didn't help.

In my case, after looking through the Xcode build logs, I found this warning in the Bundle React Native code and images step:

Warning: build produced no sourcemaps.

It seems to be coming from this line in Sentry CLI.

I'm not very good at Rust, but hopefully this might help someone debug the issue.

@leonskim
Copy link

leonskim commented Apr 9, 2021

Hi @darrylyoung, I'm wondering if you found out what causes the URL pointing to the device path instead of the uploaded artifact. I'm not using Expo but having the same issue.

@darrylyoung
Copy link
Author

Hi, @leonskim. No, unfortunately not. Have you tried the --force-foreground suggestion mentioned above?

@leonskim
Copy link

@darrylyoung Still the same. Didn't work with --force-foreground option unfortunately.

@KochMario
Copy link

KochMario commented Jun 14, 2021

The same happens for me as well. I'm not using expo, but a raw RN project. Android works perfectly fine and source maps are uploaded automatically. On iOS I do see the info "Sentry: React Native symbol handling started" when archiving with XCode, but they never show up as artifacts in an iOS Release on Sentry.

image

image
image

After reading through this issue I tried using --force-foreground as well - as can be seen in the above XCode configuration -, but to no avail.
I'm using @sentry/react-native v2.4.2 currently.


Edit: My bad, I added --force-foreground to the wrong build phase, after correctly applying it to "Bundle React Native code and images" it now correctly uploaded the 2 artifacts for the new release",

@zackify
Copy link

zackify commented Aug 12, 2021

This is a big problem.

There's nothing in the docs about it, just says "by default sourcemaps are uploaded with the react native sdk"

luckily found this issue, and was able to add --force-foreground and now i can see errors and the stack trace.

I just installed the latest version today and it wasn't working, would be good to get this patched.

@ghasemikasra39
Copy link

ghasemikasra39 commented Sep 14, 2021

I am using "@sentry/react-native": "^3.0.3". Adding --force-foreground did not help:
Screenshot 2021-09-14 at 12 09 21
Screenshot 2021-09-14 at 11 08 29
Screenshot 2021-09-14 at 11 07 21
Screenshot 2021-09-14 at 11 05 46

Update: I tested the latest version3.1.0 and got the same issue

@likrot
Copy link

likrot commented Sep 21, 2021

@ghasemikasra39 hi, what kind of build have you done? For me, it works only with release/archived versions. When I build debug version dysm file is not uplaoded.

@ghasemikasra39
Copy link

@likrot It only works on release versions. If you upload the source maps manually (like me), remove the steps above from your build phases.

@marandaneto
Copy link
Contributor

@jennmueng do you know if we should do something about this?

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2021

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 label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


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

@jennmueng
Copy link
Member

@marandaneto This issue seems to me to also be just #1424, which relies on getsentry/sentry-cli#932 (comment). Let's close this one in favor of #1424.

@biomancer
Copy link

In my case adding --force-foreground did not help, but removing NODE_ARGS environment variable did — getsentry/sentry-cli#1039

@kahest kahest added the Expo Issues related to Sentry React Native Expo support label Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Expo Issues related to Sentry React Native Expo support Platform: Cocoa
Projects
None yet
Development

No branches or pull requests