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

IOS build: Sentry fails with RN 0.75 #4036

Closed
5 of 11 tasks
theJovian opened this issue Aug 20, 2024 · 26 comments · Fixed by getsentry/sentry-cli#2131
Closed
5 of 11 tasks

IOS build: Sentry fails with RN 0.75 #4036

theJovian opened this issue Aug 20, 2024 · 26 comments · Fixed by getsentry/sentry-cli#2131

Comments

@theJovian
Copy link

theJovian commented Aug 20, 2024

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

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

SDK version: 5.30.0

react-native version: 0.75.1

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

If you are using sentry.io, please post a link to your issue so we can take a look: N/A

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'https://b62248221f8eb3d25d64fbea47abcfce@o4507570411208704.ingest.de.sentry.io/4507808288407632',
});

I have the following issue:

The following error appears when building for ios in release

Image

Steps to reproduce:

  • In XCode build from a scheme with Build Configuration set to Release

Actual result:

Build fails

Expected result:

Build succeeds

@sbeigel
Copy link

sbeigel commented Aug 20, 2024

Same. I checked it and the Sentry CLI seems to overwrite the $NODE_BINARY env variable. I added a echo $NODE_BINARY in react-native-xcode.sh and the output shows the sentry cli, not /path/to/node

A workaround for now (at least for me) is, to patch react-native-xcode.sh and replace the env var with the (locally correct) hard-coded node path (i.e. just "node" or "/usr/local/bin/node" or whatever).

@krystofwoldrich
Copy link
Member

krystofwoldrich commented Aug 20, 2024

Hi @theJovian and @sbeigel,

thank you for the report, the React Native new xcode script is currently not compatible with the sentry stript out of the box. We will fix this soon.

You can use the following workaround, manually set the new React Native config command.

export CONFIG_CMD="$NODE_BINARY $NODE_ARGS $REACT_NATIVE_PATH/cli.js config"
export CONFIG_APP="${CONFIG_CMD}"

@krystofwoldrich
Copy link
Member

We will need to investigate why https://github.com/getsentry/sentry-cli/blob/a2a4d543f4d191db553f7b1b3385c5cd0c9cfefd/src/commands/react_native/xcode.rs#L425 doesn't execute the https://github.com/getsentry/sentry-cli/blob/a2a4d543f4d191db553f7b1b3385c5cd0c9cfefd/src/commands/react_native/xcode.rs#L425
correctly.

@xuanmai-agilityio
Copy link

xuanmai-agilityio commented Aug 25, 2024

I see one more issue with Bundle React Native code and images patch script. It will not bundle the main.jsbundle and assets to the ipa file when archiving, making the app crash on start. Btw, I'm using Sentry with Nx monorepo.

@krystofwoldrich
Copy link
Member

@xuanmai-agilityio Has this change with upgrade to 0.75? And the workaround from #4036 (comment) doesn't work?

@jieey1140
Copy link

same issue

@xuanmai-agilityio
Copy link

@krystofwoldrich Do you mean to update the Bundle React Native code and images like this? Just tried but it didn't work.

Image

@theJovian
Copy link
Author

Based on this comment: #4036 (comment)

We got something like this and is working for us:

Image

Maybe we are missing $NODE_ARGS though

@krystofwoldrich
Copy link
Member

@xuanmai-agilityio @theJovian Yes, both looks good.

The missing $NODE_ARGS are okay, unless you are using them yourself, by default they are empty.

@krystofwoldrich
Copy link
Member

I've update the code snippet.

This is now easy copy paste.

export CONFIG_CMD="$NODE_BINARY $NODE_ARGS $REACT_NATIVE_PATH/cli.js config"
export CONFIG_APP="${CONFIG_CMD}"

The snippet will work with the future fix in the RN script.

As well as the Sentry CLI fix.

@xuanmai-agilityio
Copy link

It didn't work on my end with the fix below. Furthermore, I'm also using the Nx mono repo. Are there any differences in configuring on a mono repo?

Image

@krystofwoldrich
Copy link
Member

@xuanmai-agilityio Do you get any errors?

@alexborton
Copy link

Would you anticipate this working within a CircleCI environment during build?

@kahest
Copy link
Member

kahest commented Aug 27, 2024

Report of this still happening with 5.31.0 (with new arch enabled): #4052

@kahest kahest reopened this Aug 27, 2024
@lovegaoshi
Copy link

the same error in the linked issue above persists with RN 0.75.2, sentry 5.31.0 with the old architecture built with github actions. safe to say sentry is still not compatible with RN 0.75 right now

2024-08-27T19:12:31.0110520Z + EXTRA_ARGS+=("--config-cmd" "$NODE_BINARY $NODE_ARGS $REACT_NATIVE_DIR/cli.js config")
2024-08-27T19:12:31.0116630Z + /Users/runner/work/azusa-player-mobile/azusa-player-mobile/node_modules/@sentry/cli-darwin/bin/sentry-cli /Users/runner/work/azusa-player-mobile/azusa-player-mobile/node_modules/react-native/scripts/bundle.js --config-cmd '' --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/runner/Library/Developer/Xcode/DerivedData/example-dogmvunyynjjkkhewueaqvycrhvv/Build/Intermediates.noindex/ArchiveIntermediates/APM/BuildProductsPath/Release-iphoneos/main.jsbundle --assets-dest /Users/runner/Library/Developer/Xcode/DerivedData/example-dogmvunyynjjkkhewueaqvycrhvv/Build/Intermediates.noindex/ArchiveIntermediates/APM/BuildProductsPath/Release-iphoneos/AzusaPlayer.app --sourcemap-output /Users/runner/Library/Developer/Xcode/DerivedData/example-dogmvunyynjjkkhewueaqvycrhvv/Build/Intermediates.noindex/ArchiveIntermediates/APM/BuildProductsPath/Release-iphoneos/main.jsbundle.map --minify false --config-cmd '/Users/runner/work/azusa-player-mobile/azusa-player-mobile/node_modules/@sentry/cli-darwin/bin/sentry-cli  /Users/runner/work/azusa-player-mobile/azusa-player-mobile/node_modules/react-native/cli.js config'
2024-08-27T19:12:31.0122770Z error: unrecognized subcommand '/Users/runner/work/azusa-player-mobile/azusa-player-mobile/node_modules/react-native/cli.js'
2024-08-27T19:12:31.0123330Z 
2024-08-27T19:12:31.0123500Z Usage: sentry-cli [OPTIONS] <COMMAND>
2024-08-27T19:12:31.0123730Z 
2024-08-27T19:12:31.0123900Z For more information, try '--help'.
2024-08-27T19:12:31.0124430Z node:internal/errors:984
2024-08-27T19:12:31.0124740Z   const err = new Error(message);
2024-08-27T19:12:31.0125030Z               ^
2024-08-27T19:12:31.0125170Z 
2024-08-27T19:12:31.0126290Z Error: Command failed: /Users/runner/work/azusa-player-mobile/azusa-player-mobile/node_modules/@sentry/cli-darwin/bin/sentry-cli  /Users/runner/work/azusa-player-mobile/azusa-player-mobile/node_modules/react-native/cli.js config
2024-08-27T19:12:31.0127840Z error: unrecognized subcommand '/Users/runner/work/azusa-player-mobile/azusa-player-mobile/node_modules/react-native/cli.js'

https://productionresultssa3.blob.core.windows.net/actions-results/9e21290a-4def-4020-8129-fc95fb60a04e/workflow-job-run-eae0f608-ea3b-5872-5780-858ef628eb1e/logs/job/job-logs.txt?rsct=text%2Fplain&se=2024-08-27T19%3A24%3A45Z&sig=LibEVq%2FyW8MQcZCEcXe9V%2FzVqY7v%2B%2BKf9Irllgh6SFU%3D&ske=2024-08-28T03%3A26%3A58Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2024-08-27T15%3A26%3A58Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2024-05-04&sp=r&spr=https&sr=b&st=2024-08-27T19%3A14%3A40Z&sv=2024-05-04

@abdoerrahiem
Copy link

got the same issue

@xuanmai-agilityio
Copy link

Got this issue when running with updated Bundle React Native code and images scripts.

Error: Command failed: /Users/maixuan/Develop/AsNet/AgilityKash/apps/consumer-mobile/ios/Pods/../../node_modules/react-native/cli.js config
env: node: No such file or directory

    at checkExecSyncError (node:child_process:890:11)

@sbeigel
Copy link

sbeigel commented Aug 28, 2024

I'm not a sentry developer, but to me it looks like this issue is fixed by #2131 but this fix is NOT released yet and NEITHER included in @sentry/react-native. So we have to wait for that (and use custom patches until it's released).

@kahest
Copy link
Member

kahest commented Aug 28, 2024

@sbeigel that's correct, the fix needs to be released with sentry-cli and then bumped in @sentry/react-native. We'll update this issue when it becomes available.

@krystofwoldrich
Copy link
Member

@xuanmai-agilityio For monorepos you will need to adjust the path to the react-native package.

Based on the error you got, something like this should work.

export CONFIG_CMD="$NODE_BINARY $NODE_ARGS ../../../../node_modules/react-native/cli.js config"
export CONFIG_APP="${CONFIG_CMD}"

@krystofwoldrich
Copy link
Member

Fix released in 5.31.1

@Asad520
Copy link

Asad520 commented Aug 29, 2024

I am getting still facing an error on 5.31.1.

No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
*** Terminating app due to uncaught exception 'RCTFatalException: No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.', reason: 'No bundle URL present.

These are my project versions (I'm not using expo):

"@sentry/react-native": "^5.31.1",
    "react": "18.3.1",
    "react-native": "0.75.1"

These are the content from Bundle React Native code and Images (auto-generated):

set -e

WITH_ENVIRONMENT="$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="$REACT_NATIVE_PATH/scripts/react-native-xcode.sh"

/bin/sh -c "$WITH_ENVIRONMENT \"\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\"\""

and these are in Upload Debug Symbols to Sentry (also auto-generated):

/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh

The issue doesn't exist if I remove Sentry. Is this related to the parent issue? or any work arounds?

@jieey1140
Copy link

@Asad520

It seems to work with pnpm monorepo + React Native 0.75.2 + sentry 5.31.1.

Not finding the above jsbundle seems to be a different issue!

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 \"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\""

How about trying the above?

@Asad520
Copy link

Asad520 commented Aug 30, 2024

@jieey1140 The script you provided worked for me. Thank you! 🥳

@chrisfinch
Copy link

chrisfinch commented Sep 8, 2024

Still getting this issue:

"react-native": "^0.75.2",
"@sentry/react-native": "^5.31.1",
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 \"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\""

▸ Running script 'Bundle React Native code and images'

❌  error: sentry-cli - To disable source maps auto upload, set SENTRY_DISABLE_AUTO_UPLOAD=true in your environment variables. Or to allow failing upload, set SENTRY_ALLOW_FAILURE=true



❌  error: sentry-cli -   INFO    2024-09-07 22:48:57.253587 -07:00 Loaded file referenced by SENTRY_PROPERTIES (sentry.properties)



❌  error: unrecognized subcommand '/Users/christopherfinch/Projects/KeyhiveIoPhoneApp/node_modules/react-native/cli.js'



❌  error: unrecognized subcommand '/Users/christopherfinch/Projects/KeyhiveIoPhoneApp/node_modules/react-native/cli.js'

I've now wasted many hours trying to debug. My next step is removing sentry altogether.

Please advise.

cc @krystofwoldrich

@krystofwoldrich
Copy link
Member

Hi @chrisfinch,

I'm sorry to hear that.

If you are running in the auto upload issue, you can always use SENTRY_DISABLE_AUTO_UPLOAD=true, to build the application without the auto source maps upload and then run the comman manually https://docs.sentry.io/platforms/react-native/sourcemaps/


Based on the output, the sentry-xcode.sh is still using the old version of sentry-cli.

The script uses the Node JS resolution to get the binary require.resolve('@sentry/cli/package.json') possibly you have multiple version of the Sentry CLI installed.

You can try to run node --print "require('path').dirname(require.resolve('@sentry/cli/package.json'))" in the RN project root to check the path resolves. You can also use SENTRY_CLI_EXECUTABLE env to manually select the path or install the sentry-cli@latest JS package manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.