getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.59k stars 337 forks source link

Support for Gradle Configuration Cache #4252

Open smellouk opened 2 weeks ago

smellouk commented 2 weeks ago

What React Native libraries do you use?

React Native without Frameworks

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

5.25.0

How does your development environment look like?

OS: mac-os arch: arm64 react native: 0.74.3-0 hermes enabled: true

Sentry.init()

 sentry.init({
        dsn: sentryConfig.dsn,
        release: sentryConfig.release,
        enabled: sentryConfig.enabled,
        autoSessionTracking: false,
        ignoreErrors: [],
    });

Steps to Reproduce

  1. Export SENTRY_DISABLE_AUTO_UPLOAD=false
  2. Export SENTRY_AUTH_TOKEN=YOUR_TOKEN
  3. enable org.gradle.configuration-cache=true in gradle.properties
  4. set warn level for configuration cache problems org.gradle.unsafe.configuration-cache-problems=warn in gradle properties
  5. build release app apk or bundle ./gradlew assembleRelease

Expected Result

Building/Assembling APK or bundle tasks should succeed without error.

Actual Result

See the complete report at .../configuration-cache/arbf12exyse0x2d67zxpdnb38/e07xbrg4hyz0msuzuubqcqzuy/configuration-cache-report.html

FAILURE: Build failed with an exception.

* Where:
Script '.../node_modules/@sentry/react-native/sentry.gradle' line: 104

* What went wrong:
Could not evaluate onlyIf predicate for task ':app:createBundleReleaseJsAndAssets_SentryUpload_PACKAGE_ID@VERSION_NAME+VERSION_CODE'.
> Could not evaluate spec for 'Task satisfies onlyIf closure'.
krystofwoldrich commented 4 days ago

Hi @smellouk, thank you for the report and the detailed steps, I was able to reproduce the issue in our sample application.

At the moment the Gradle configuration cache doesn't support all gradle features, some of the unsupported features are used in the sentry.gradle.

I can't confirm at the moment if we are able to work around the current gradle configuration cache limitations.


As a workaround, you can exclude the sentry.gradle and upload source maps manually.

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

smellouk commented 3 days ago

@krystofwoldrich Thanks so much for looking into this matter 🙏!

We’re working on a project that’s growing in complexity, and we’d like to optimize the Gradle configuration to reduce assembly time. Additionally, we have some automation tasks in place, and as a one-time setup, we’d like to enable the automatic upload of sourcemaps and ProGuard mappings.

It’s not urgent for now, we disabled our gradle configuration cache for now, but we’d appreciate your help when possible.

krystofwoldrich commented 3 days ago

@romtsn @markushi @stefanosiano Our current sentry.gradle script doesn't work with Gradle Configuration Cache, before we would start refactor of it to support the cache, I want to check does SAGP support Gradle Configuration Cache?