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] Packager source map not found when composing final source map #3751

Closed
5 of 11 tasks
yzlin opened this issue Apr 9, 2024 · 7 comments
Closed
5 of 11 tasks

[iOS] Packager source map not found when composing final source map #3751

yzlin opened this issue Apr 9, 2024 · 7 comments

Comments

@yzlin
Copy link

yzlin commented Apr 9, 2024

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

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

SDK version: 5.20.0

react-native version: 0.73.6

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

Configuration:

(@sentry/react-native)

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

I have the following issue:

Failed to upload source maps while archiving

+ HBC_SOURCEMAP_FILE=/Users/yzlin/Library/Developer/Xcode/DerivedData/ClientSlatedNative-cmygoxgvryogdofjmxlmlhicsmoz/Build/Intermediates.noindex/ArchiveIntermediates/ClientSlatedNative/BuildProductsPath/Release-iphoneos/Slated.app/main.jsbundle.map
+ /Users/yzlin/dev/hajimari-labs/client-slated-native/node_modules/@sentry/cli-darwin/bin/sentry-cli /Users/yzlin/dev/hajimari-labs/client-slated-native/node_modules/react-native/scripts/compose-source-maps.js /Users/yzlin/Library/Developer/Xcode/DerivedData/ClientSlatedNative-cmygoxgvryogdofjmxlmlhicsmoz/Build/Intermediates.noindex/ArchiveIntermediates/ClientSlatedNative/BuildProductsPath/Release-iphoneos/main.jsbundle.map /Users/yzlin/Library/Developer/Xcode/DerivedData/ClientSlatedNative-cmygoxgvryogdofjmxlmlhicsmoz/Build/Intermediates.noindex/ArchiveIntermediates/ClientSlatedNative/BuildProductsPath/Release-iphoneos/Slated.app/main.jsbundle.map -o /Users/yzlin/Library/Developer/Xcode/DerivedData/ClientSlatedNative-cmygoxgvryogdofjmxlmlhicsmoz/Build/Intermediates.noindex/ArchiveIntermediates/ClientSlatedNative/IntermediateBuildFilesPath/ClientSlatedNative.build/Release-iphoneos/ClientSlatedNative.build/DerivedSources/main.jsbundle.map
node:internal/fs/utils:351
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/Users/yzlin/Library/Developer/Xcode/DerivedData/ClientSlatedNative-cmygoxgvryogdofjmxlmlhicsmoz/Build/Intermediates.noindex/ArchiveIntermediates/ClientSlatedNative/BuildProductsPath/Release-iphoneos/main.jsbundle.map'
    at Object.openSync (node:fs:596:3)
    at Object.readFileSync (node:fs:464:35)
    at Object.<anonymous> (/Users/yzlin/dev/hajimari-labs/client-slated-native/node_modules/react-native/scripts/compose-source-maps.js:34:8)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
    at node:internal/main/run_main_module:28:49 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/Users/yzlin/Library/Developer/Xcode/DerivedData/ClientSlatedNative-cmygoxgvryogdofjmxlmlhicsmoz/Build/Intermediates.noindex/ArchiveIntermediates/ClientSlatedNative/BuildProductsPath/Release-iphoneos/main.jsbundle.map'
}

Node.js v18.19.0
Command PhaseScriptExecution failed with a nonzero exit code
@krystofwoldrich
Copy link
Member

Hi @yzlin,
thank you for the message,
reading from the error the Metro packager didn't produce source map to the expected path and the RN tooling failed when composing packager and Hermes source map.

Typically this is caused by white space characters on the path, but I don't see those in the log.

Can you share steps how you step your application and how does your Bundle React Native code and images build phase looks like?

@krystofwoldrich krystofwoldrich changed the title Unable to upload source maps [iOS] Packager source map not found when composing final source map Apr 10, 2024
@yzlin
Copy link
Author

yzlin commented Apr 10, 2024

Hi @yzlin, thank you for the message, reading from the error the Metro packager didn't produce source map to the expected path and the RN tooling failed when composing packager and Hermes source map.

Typically this is caused by white space characters on the path, but I don't see those in the log.

Can you share steps how you step your application and how does your Bundle React Native code and images build phase looks like?

Hi @krystofwoldrich,

I followed docs to install sentry via wizard, opened Xcode and archived the app. Before sentry modified Bundle React Native code and images, the archive worked.

here's the build phrase:

export EXTRA_PACKAGER_ARGS="--sourcemap-output $TMPDIR/$(md5 -qs "$CONFIGURATION_BUILD_DIR")-main.jsbundle.map"
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\""

Build log

@lab900-guillian-bouchier
Copy link

lab900-guillian-bouchier commented Apr 24, 2024

I'm also facing this issue after upgrading both RN (0.73.6) & Sentry (5.22.0)

Here the command and output from metro bundling

+ /Users/runner/work/1/s/node_modules/@sentry/cli-darwin/bin/sentry-cli /Users/runner/work/1/s/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/runner/Library/Developer/Xcode/DerivedData/bits-bczlxsvjhhkhefbbqhxyanfvbkeo/Build/Intermediates.noindex/ArchiveIntermediates/bits/BuildProductsPath/Release-iphoneos/main.jsbundle --assets-dest /Users/runner/Library/Developer/Xcode/DerivedData/bits-bczlxsvjhhkhefbbqhxyanfvbkeo/Build/Intermediates.noindex/ArchiveIntermediates/bits/BuildProductsPath/Release-iphoneos/BITS.app --sourcemap-output /Users/runner/Library/Developer/Xcode/DerivedData/bits-bczlxsvjhhkhefbbqhxyanfvbkeo/Build/Intermediates.noindex/ArchiveIntermediates/bits/BuildProductsPath/Release-iphoneos/main.jsbundle.map --minify false --sourcemap-output /Users/runner/Library/Developer/Xcode/DerivedData/bits-bczlxsvjhhkhefbbqhxyanfvbkeo/Build/Intermediates.noindex/ArchiveIntermediates/bits/IntermediateBuildFilesPath/BITS.build/Release-iphoneos/bits.build/DerivedSources/main.jsbundle.map
warning: the transform cache was reset.
                Welcome to Metro v0.80.8
              Fast - Scalable - Integrated


info Writing bundle output to:, /Users/runner/Library/Developer/Xcode/DerivedData/bits-bczlxsvjhhkhefbbqhxyanfvbkeo/Build/Intermediates.noindex/ArchiveIntermediates/bits/BuildProductsPath/Release-iphoneos/main.jsbundle
info Writing sourcemap output to:, /Users/runner/Library/Developer/Xcode/DerivedData/bits-bczlxsvjhhkhefbbqhxyanfvbkeo/Build/Intermediates.noindex/ArchiveIntermediates/bits/IntermediateBuildFilesPath/BITS.build/Release-iphoneos/bits.build/DerivedSources/main.jsbundle.map

And then later on when Sentry tries to load the files

+ /Users/runner/work/1/s/node_modules/@sentry/cli-darwin/bin/sentry-cli /Users/runner/work/1/s/node_modules/react-native/scripts/compose-source-maps.js /Users/runner/Library/Developer/Xcode/DerivedData/bits-bczlxsvjhhkhefbbqhxyanfvbkeo/Build/Intermediates.noindex/ArchiveIntermediates/bits/BuildProductsPath/Release-iphoneos/main.jsbundle.map /Users/runner/Library/Developer/Xcode/DerivedData/bits-bczlxsvjhhkhefbbqhxyanfvbkeo/Build/Intermediates.noindex/ArchiveIntermediates/bits/BuildProductsPath/Release-iphoneos/BITS.app/main.jsbundle.map -o /Users/runner/Library/Developer/Xcode/DerivedData/bits-bczlxsvjhhkhefbbqhxyanfvbkeo/Build/Intermediates.noindex/ArchiveIntermediates/bits/IntermediateBuildFilesPath/BITS.build/Release-iphoneos/bits.build/DerivedSources/main.jsbundle.map
node:internal/fs/utils:356
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/Users/runner/Library/Developer/Xcode/DerivedData/bits-bczlxsvjhhkhefbbqhxyanfvbkeo/Build/Intermediates.noindex/ArchiveIntermediates/bits/BuildProductsPath/Release-iphoneos/main.jsbundle.map'
    at Object.openSync (node:fs:596:3)
    at Object.readFileSync (node:fs:464:35)
    at Object.<anonymous> (/Users/runner/work/1/s/node_modules/react-native/scripts/compose-source-maps.js:34:8)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
    at node:internal/main/run_main_module:28:49 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/Users/runner/Library/Developer/Xcode/DerivedData/bits-bczlxsvjhhkhefbbqhxyanfvbkeo/Build/Intermediates.noindex/ArchiveIntermediates/bits/BuildProductsPath/Release-iphoneos/main.jsbundle.map'
}

Node.js v18.20.2
Command PhaseScriptExecution failed with a nonzero exit code

So it seems like the main.jsbundle.map file is being put in a different directory by metro compared to the main.jsbundle file which is causing Sentry to fail?

Is there any fix for this?

@krystofwoldrich
Copy link
Member

Hi @yzlin excuse the delayed reply,

the issue is export EXTRA_PACKAGER_ARGS="--sourcemap-output $TMPDIR/$(md5 -qs "$CONFIGURATION_BUILD_DIR")-main.jsbundle.map" set -e if you remove this line the source maps will be created correctly and will be located.

Alternatively you if you want to specify your path to the source maps use SOURCEMAP_FILE variable.
https://reactnative.dev/docs/debugging-release-builds#enabling-source-maps

@krystofwoldrich
Copy link
Member

@lab900-guillian-bouchier Can you share with use your Xcode Bundle React Native code and images build phase?

If you are using EXTRA_PACKAGER_ARGS switch to SOURCEMAP_FILE and the source map should be located correctly.

@lab900-guillian-bouchier

@lab900-guillian-bouchier Can you share with use your Xcode Bundle React Native code and images build phase?

If you are using EXTRA_PACKAGER_ARGS switch to SOURCEMAP_FILE and the source map should be located correctly.

Hi @krystofwoldrich,

Below is my build phase script

set -x
export SENTRY_PROPERTIES="$PROJECT_DIR/sentry.properties"
export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"

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\""

So should I change the 2nd export to SOURCEMAP_FILE or does something else need to be changed?

@Elvinra
Copy link

Elvinra commented Apr 25, 2024

I was having the same problem.

So after migrating from the variable "EXTRA_PACKAGER_ARGS" to

export SOURCEMAP_FILE="$DERIVED_FILE_DIR/main.jsbundle.map"

Everything works normally

And be care like it was said earlier, any space in the path of the file, broke the script.
Generally if you have custom scheme on Xcode.

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

No branches or pull requests

5 participants