getsentry / sentry-react-native

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

Sentry v6: error: bad json: duplicate field `debug_id` at line 1 column 45849017 #4323

Open blumk opened 3 days ago

blumk commented 3 days ago

What React Native libraries do you use?

React Navigation, Hermes, React Native without Frameworks

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

6.3.0

How does your development environment look like?

System: OS: macOS 14.7.1 CPU: (12) arm64 Apple M2 Max Memory: 1.56 GB / 64.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 20.11.0 path: ~/.nvm/versions/node/v20.11.0/bin/node Yarn: Not Found npm: version: 10.8.2 path: ~/.nvm/versions/node/v20.11.0/bin/npm Watchman: version: 2024.10.07.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.16.2 path: /Users/xxx/.rbenv/shims/pod SDKs: iOS SDK: Platforms:

Sentry.init()

Sentry.init({ environment: process.env.SENTRY_ENV ?? 'local-dev', dsn: process.env.SENTRY_DSN, release: process.env.SENTRY_RELEASE, dist: process.env.SENTRY_DIST, // autoInitializeNativeSdk set to false with iOS because it is already initialized in AppDelegate.m autoInitializeNativeSdk: false, });

Steps to Reproduce

Upgrading to v6 of @sentry/react-native causes both iOS/Android builds to fail.

iOS build fails with:

❌  error: bad json: duplicate field `debug_id` at line 1 column 45849017

Build command:

npm install
RCT_NEW_ARCH_ENABLED=0 PRODUCTION=1 bundle exec pod install
bundle exec fastlane ios

GitHub workflow

      - name: Upload debug symbols to Sentry
        continue-on-error: true
        run: |
          ${{ github.workspace }}/xxx/node_modules/@sentry/cli/bin/sentry-cli debug-files upload --include-sources --org $SENTRY_ORG --project $SENTRY_PROJECT ${{ github.workspace }}/xxx/dSYMs/

Expected Result

No build error.

Actual Result

❌  error: bad json: duplicate field `debug_id` at line 1 column 45849017
krystofwoldrich commented 2 days ago

Hi @blumk, thank you for the message,

could you share with us your metro.config.js and a large portion of the iOS build log? (What is the build phase the process fails on? Bundle React Native code and images?)

blumk commented 7 hours ago

Hi @blumk, thank you for the message,

could you share with us your metro.config.js and a large portion of the iOS build log? (What is the build phase the process fails on? Bundle React Native code and images?)

Thanks for looking into this! Happy to share more info:

metro.config.js:

/**
 * Metro configuration
 * https://reactnative.dev/docs/metro
 *
 */

const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const defaultConfig = getDefaultConfig(__dirname);
const { assetExts, sourceExts } = defaultConfig.resolver;
const exclusionList = require('metro-config/src/defaults/exclusionList');
const path = require('path');
const {
  createSentryMetroSerializer,
} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');

const repoDir = path.normalize(path.join(__dirname, '..'));
const zzzNodeModulesDir = path.join(repoDir, 'zzz', 'node_modules');

/**
 * @type {import('metro-config').MetroConfig}
 */
const rnGestureHandlerConfig = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
};

/**
 * @type {import('metro-config').MetroConfig}
 */
const config = {
  transformer: {
    babelTransformerPath: require.resolve('react-native-svg-transformer'),
    minifierPath: 'metro-minify-terser',
    minifierConfig: {
      ecma: 8,
      keep_classnames: true,
      keep_fnames: true,
      module: true,
      mangle: {
        module: true,
        keep_classnames: true,
        keep_fnames: true,
      },
    },
  },
  resolver: {
    assetExts: assetExts.filter((ext) => ext !== 'svg'),
    sourceExts: [...sourceExts, 'svg', 'cjs', 'mjs'],
    aasa: 'apple-app-site-association',
    blockList: exclusionList([/patches\/.*/]),
    unstable_enableSymlinks: true,
    extraNodeModules: {
      react: path.join(zzzNodeModulesDir, 'react'),
      'react-native': path.join(zzzNodeModulesDir, 'react-native'),
    },
    nodeModulesPaths: [zzzNodeModulesDir],
  },
  watchFolders: [`${repoDir}/PasswordStorage`, `${repoDir}/BiosensorModule`],
  serializer: {
    customSerializer: createSentryMetroSerializer(),
  },
};

module.exports = mergeConfig(defaultConfig, config, rnGestureHandlerConfig);

iOS build log:

...createElement('canvas') : new OffscreenCanvas(1, 1);
                                  ^~~~~~~~~~~~

⚠️  /Users/fastlaneios/Library/Developer/Xcode/DerivedData/zzz-emoocznjdksqjvdaarwnoiwzhzqr/Build/Intermediates.noindex/ArchiveIntermediates/zzz/BuildProductsPath/Release-iphoneos/main.jsbundle:453544:34: the variable "ImageBitmap" was not declared in function "?anon_0_ 1317#"

      var isImageBitmap = typeof ImageBitmap !== 'undefined' && image instanc...
                                 ^~~~~~~~~~~~~~~

⚠️  /Users/fastlaneios/Library/Developer/Xcode/DerivedData/zzz-emoocznjdksqjvdaarwnoiwzhzqr/Build/Intermediates.noindex/ArchiveIntermediates/zzz/BuildProductsPath/Release-iphoneos/main.jsbundle:453656:30: the variable "Image" was not declared in anonymous function " 16291#"

          var newImage = new Image();
                                 ^~~~~~~~~~~

❌  error: bad json: duplicate field `debug_id` at line 1 column 45849017

[17:23:01]: ```
[17:23:01]:     270:        use_workspace = !ENV['WORKSPACE_PATH'].empty?
[17:23:01]:     271:        use_build_destination = !ENV['BUILD_DESTINATION'].empty?
[17:23:01]:  => 272:        build_app(
[17:23:01]:     273:          workspace: use_workspace ? ENV['WORKSPACE_PATH'] : nil,
[17:23:01]:     274:          project: !use_workspace ? ENV['PROJECT_PATH'] : nil,
[17:23:01]: ```
[17:23:01]: Error building the application - see the log above

+-----------------------------------------------------------------+
|                        fastlane summary                         |
+------+--------------------------------------------+-------------+
| Step | Action                                     | Time (in s) |
+------+--------------------------------------------+-------------+
| 1    | Verifying Ruby version                     | 0           |
| 2    | unlock_keychain                            | 0           |
| 3    | Switch to ios_build_number lane            | 0           |
| 4    | Switch to ios_update_project_metadata lane | 0           |
| 5    | Switch to ios_prepare_project lane         | 0           |
| 6    | match                                      | 0           |
| 7    | update_info_plist                          | 0           |
| 8    | update_code_signing_settings               | 0           |
| 9    | update_project_provisioning                | 0           |
| 10   | update_app_identifier                      | 0           |
| 11   | update_project_team                        | 0           |
| 12   | Switch to ios_build lane                   | 0           |
| 💥   | build_app                                  | 852         |
+------+--------------------------------------------+-------------+

[17:23:01]: fastlane finished with errors
Error: Process completed with exit code 1.