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

fix build multi variant releases #4125

Conversation

omidshafaei
Copy link
Contributor

@omidshafaei omidshafaei commented Sep 28, 2024

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

When I want to build for multi-variant projects, it gives me an error.
During troubleshooting, I realized that for all variants, only one version of the source map is uploaded.
By checking the sentry .gradle file, I realized that three variables are defined globally, but they are used inside the loop, and this makes these three variables retain the value of the last round of the loop. For this reason, the duplicate source map is uploaded.
For example, if I want to build for armeabi-v7a, x86, arm64-v8a and x86_64 variants, the source map for x86_64 will be uploaded four times because it is the last round of the loop.

💡 Motivation and Context

This pull request solves the problem of duplicate source map upload for all project variants.

💚 How did you test it?

Just create a multi-variant project and build it.
This is my build logs. As you can see, one version has been uploaded for all source map upload tasks:

> Task :app:createBundleReleaseJsAndAssets_SentryUpload_com.x.appr@0.8.9+8009003_8009003
Copy `debugId` from packager source map to Hermes source map...
Hermes combined source map already has `debugId`.
Check generated source map for Debug ID: 459c09a1-1fc3-4f9a-bde8-0b99536bcaf4

Sentry Source Maps upload will include the release name and dist.
Sentry-CLI arguments: [C:\Projects\x-next\node_modules\@sentry\cli\bin\sentry-cli, react-native, gradle, --bundle, C:\Projects\x-next\android\app\build\generated\assets\createBundleReleaseJsAndAssets\index.android.bundle, --sourcemap, C:\Projects\x-next\android\app\build\generated\sourcemaps\react\release\index.android.bundle.map, --release, com.x.appr@0.8.9+8009004, --dist, 8009004]
  INFO    2024-09-09 12:01:05.529249800 +03:30 Loaded file referenced by SENTRY_PROPERTIES (C:\Projects\x-next/android/sentry.properties)
  WARN    2024-09-09 12:01:05.529461300 +03:30 Unrecognized auth token format!
        Hint: Did you copy your token correctly?
Processing react-native sourcemaps for Sentry upload.
> Analyzing 2 sources
> Rewriting sources
> Adding source map references
Uploading sourcemaps for release com.x.appr@0.8.9+8009004 distribution 8009004
> Bundled 2 files for upload
> Bundle ID: 198959e3-bba9-5efa-ac3d-10659819e71d
> Nothing to upload, all files are on the server
error: Failed to process uploaded files: internal server error

Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
Please attach the full debug log to all bug reports.

> Task :app:createBundleReleaseJsAndAssets_SentryUpload_com.x.appr@0.8.9+8009003_8009003 FAILED

> Task :app:createBundleReleaseJsAndAssets_SentryUpload_com.x.appr@0.8.9+8009001_8009001
Copy `debugId` from packager source map to Hermes source map...
Hermes combined source map already has `debugId`.
Check generated source map for Debug ID: 459c09a1-1fc3-4f9a-bde8-0b99536bcaf4

Sentry Source Maps upload will include the release name and dist.
Sentry-CLI arguments: [C:\Projects\x-next\node_modules\@sentry\cli\bin\sentry-cli, react-native, gradle, --bundle, C:\Projects\x-next\android\app\build\generated\assets\createBundleReleaseJsAndAssets\index.android.bundle, --sourcemap, C:\Projects\x-next\android\app\build\generated\sourcemaps\react\release\index.android.bundle.map, --release, com.x.appr@0.8.9+8009004, --dist, 8009004]
  INFO    2024-09-09 12:01:09.001800500 +03:30 Loaded file referenced by SENTRY_PROPERTIES (C:\Projects\x-next/android/sentry.properties)
  WARN    2024-09-09 12:01:09.001992400 +03:30 Unrecognized auth token format!
        Hint: Did you copy your token correctly?
Processing react-native sourcemaps for Sentry upload.
> Analyzing 2 sources
> Rewriting sources
> Adding source map references
Uploading sourcemaps for release com.x.appr@0.8.9+8009004 distribution 8009004
> Bundled 2 files for upload
> Bundle ID: 198959e3-bba9-5efa-ac3d-10659819e71d
> Nothing to upload, all files are on the server
error: Failed to process uploaded files: internal server error

Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
Please attach the full debug log to all bug reports.

> Task :app:createBundleReleaseJsAndAssets_SentryUpload_com.x.appr@0.8.9+8009001_8009001 FAILED

> Task :app:createBundleReleaseJsAndAssets_SentryUpload_com.x.appr@0.8.9+8009002_8009002
Copy `debugId` from packager source map to Hermes source map...
Hermes combined source map already has `debugId`.
Check generated source map for Debug ID: 459c09a1-1fc3-4f9a-bde8-0b99536bcaf4

Sentry Source Maps upload will include the release name and dist.
Sentry-CLI arguments: [C:\Projects\x-next\node_modules\@sentry\cli\bin\sentry-cli, react-native, gradle, --bundle, C:\Projects\x-next\android\app\build\generated\assets\createBundleReleaseJsAndAssets\index.android.bundle, --sourcemap, C:\Projects\x-next\android\app\build\generated\sourcemaps\react\release\index.android.bundle.map, --release, com.x.appr@0.8.9+8009004, --dist, 8009004]
  INFO    2024-09-09 12:01:15.591834600 +03:30 Loaded file referenced by SENTRY_PROPERTIES (C:\Projects\x-next/android/sentry.properties)
  WARN    2024-09-09 12:01:15.592023500 +03:30 Unrecognized auth token format!
        Hint: Did you copy your token correctly?
Processing react-native sourcemaps for Sentry upload.
> Analyzing 2 sources
> Rewriting sources
> Adding source map references
Uploading sourcemaps for release com.x.appr@0.8.9+8009004 distribution 8009004
> Bundled 2 files for upload
> Bundle ID: 198959e3-bba9-5efa-ac3d-10659819e71d
> Nothing to upload, all files are on the server
error: Failed to process uploaded files: internal server error

Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
Please attach the full debug log to all bug reports.

> Task :app:createBundleReleaseJsAndAssets_SentryUpload_com.x.appr@0.8.9+8009002_8009002 FAILED

> Task :app:createBundleReleaseJsAndAssets_SentryUpload_com.x.appr@0.8.9+8009004_8009004
Copy `debugId` from packager source map to Hermes source map...
Hermes combined source map already has `debugId`.
Check generated source map for Debug ID: 459c09a1-1fc3-4f9a-bde8-0b99536bcaf4

Sentry Source Maps upload will include the release name and dist.
Sentry-CLI arguments: [C:\Projects\x-next\node_modules\@sentry\cli\bin\sentry-cli, react-native, gradle, --bundle, C:\Projects\x-next\android\app\build\generated\assets\createBundleReleaseJsAndAssets\index.android.bundle, --sourcemap, C:\Projects\x-next\android\app\build\generated\sourcemaps\react\release\index.android.bundle.map, --release, com.x.appr@0.8.9+8009004, --dist, 8009004]
  INFO    2024-09-09 12:01:19.087368400 +03:30 Loaded file referenced by SENTRY_PROPERTIES (C:\Projects\x-next/android/sentry.properties)
  WARN    2024-09-09 12:01:19.087563 +03:30 Unrecognized auth token format!
        Hint: Did you copy your token correctly?
Processing react-native sourcemaps for Sentry upload.
> Analyzing 2 sources
> Rewriting sources
> Adding source map references
Uploading sourcemaps for release com.x.appr@0.8.9+8009004 distribution 8009004
> Bundled 2 files for upload
> Bundle ID: 198959e3-bba9-5efa-ac3d-10659819e71d
> Nothing to upload, all files are on the server
error: Failed to process uploaded files: internal server error

Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
Please attach the full debug log to all bug reports.

> Task :app:createBundleReleaseJsAndAssets_SentryUpload_com.x.appr@0.8.9+8009004_8009004 FAILED

As can be seen in the logs above, this log has been repeated four times:
Uploading sourcemaps for release com.x.appr@0.8.9+8009004 distribution 8009004

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • All tests passing
  • No breaking changes

@lucas-zimerman
Copy link
Collaborator

Hi and thank you for the contribution!
Would you mind changing the changelog.md with the mention to this PR?
Here is an example of the modified Changelog.md:

# Changelog

## Unreleased

### Fixes

- Fix build multi variant releases on Android ([#4125](https://github.com/getsentry/sentry-react-native/pull/4125))

@krystofwoldrich
Copy link
Member

Hi @omidshafaei,
thank you for the contribution, the fix looks good, please add the changelog as @lucas-zimerman mentioned, then we can merge this.

@omidshafaei
Copy link
Contributor Author

Hi @lucas-zimerman, @krystofwoldrich.
I added my changes to the changelog

Copy link
Collaborator

@lucas-zimerman lucas-zimerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

@krystofwoldrich krystofwoldrich merged commit 2ec71da into getsentry:main Oct 7, 2024
53 of 63 checks passed
@omidshafaei omidshafaei deleted the fix/build-for-multi-variant-releases branch October 13, 2024 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants