getsentry / sentry-cli

A command line utility to work with Sentry.
https://docs.sentry.io/cli/
BSD 3-Clause "New" or "Revised" License
905 stars 222 forks source link

[Xcode, Sentry CLI] Upload fails in background #2148

Closed trooperandz closed 1 month ago

trooperandz commented 2 months ago

OS:

Platform:

SDK:

SDK version: 5.31.1

react-native version: 0.73.7

Are 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: (I do not have a link that I know of)

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'https://...sentry.io...'
});

I have the following issue:

When attempting to upload source maps and debug symbols for iOS during the release build process, the Sentry uploads only work when the foreground flag is enabled: export SENTRY_CLI_EXTRA_ARGS="--force-foreground". If the foreground flag is not set, we see in the MacOS crash logs that the sentry-cli is crashing during execution. This is with the sentry-cli version 2.34.0.

Steps to reproduce:

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

Additionally, ensure that the "Upload Debug Symbols to Sentry" build phase has the following content:

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

Image

Image

Actual result: Before adding the export SENTRY_CLI_EXTRA_ARGS="--force-foreground" environment variable, no debug files or source map uploads occur.

Expected result: Source map uploads should occur regardless of the --force-foreground flag.

Supporting logs and crash report details (see attachments)

sentry-logs-from-failed-upload.txt sentry-cli-crash1.txt sentry-cli-crash2.txt

Krupskis commented 2 months ago

Seems to be the same issue as getsentry/sentry-react-native#4063

trooperandz commented 2 months ago

Seems to be the same issue as #4063

@Krupskis I don't think that this is the same issue. Our issue was not with the main.jsbundle; it was when the bundle upload step was occurring. Our main.jsbundle file was created successfully during the process.

krystofwoldrich commented 2 months ago

Hi @trooperandz, thank you for the super detailed steps,

when uploading from background the process output is redirected to a file.

You can find the file path in the output before redirection.

output: sentry-cli - Continuing in background.
output: sentry-cli - Output is redirected to /var/folders/2k/q6nq8shs0zz25v_lsc39zjg80000gn/T/25201362-2391-40db-b6f8-f530012def6e

Can you try the upload once more and share the content of the file?

trooperandz commented 2 months ago

Thank you @krystofwoldrich . Here is the output file which you requested:

background-output-log.txt

krystofwoldrich commented 2 months ago

Thank you for the log, it seems to be the same error as

Likely caused by bump of the CLI dependency curl-sys to 0.4.73+curl-8.8.0 in https://github.com/getsentry/sentry-cli/pull/2096/files#diff-13ee4b2252c9e516a0547f2891aa2105c3ca71c6d7a1e682c69be97998dfc87eR615.

krystofwoldrich commented 2 months ago

Affected CLI versions https://github.com/getsentry/sentry-cli/releases/tag/2.32.2 to current

krystofwoldrich commented 2 months ago

@loewenheim @szokeasaurusrex Can we lock in the older version of curl-sys till a fix from the lib side or our side is provided for the latest versions?

To avoid Sentry CLI regressions by accidental upgrades in the future.

szokeasaurusrex commented 2 months ago

@krystofwoldrich, yeah, I think this should be possible

szokeasaurusrex commented 2 months ago

The fix will be available in 2.36.1, which we will release shortly

szokeasaurusrex commented 1 month ago

Reopening this issue. I was able to reproduce this issue even after downgrading curl-sys, indicating that downgrading likely did not fix the issue. Furthermore, the downgrade caused #2155, so now I plan to re-upgrade curl-sys.

We will continue investigating how to fix this issue. For now, we recommend running Sentry CLI with --force-foreground when uploading React Native debug files.