Skip to content

Panic on "doesn't contain a valid JSON data" after facebook/react-native#33146 #1247

@taylorkline

Description

@taylorkline

Environment

How do you use Sentry?

  • Sentry SaaS (sentry.io)

Which SDK and version?

  • @sentry/react-native: 3.4.2

Steps to Reproduce

I imagine this would reproduce the issue:

  • Begin a new React Native typescript template project with React Native v0.67.3.
  • Add / configure patch-package
  • Apply facebook/react-native@802b3f7 as a patch by placing in /patches/react-native+0.67.3.patch
diff --git a/node_modules/react-native/scripts/find-node.sh b/node_modules/react-native/scripts/find-node.sh
deleted file mode 100755
index 5d6d2c4..0000000
--- a/node_modules/react-native/scripts/find-node.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-# Copyright (c) Facebook, Inc. and its affiliates.
-#
-# This source code is licensed under the MIT license found in the
-# LICENSE file in the root directory of this source tree.
-
-set -e
-
-# remove global prefix if it's already set
-# the running shell process will choose a node binary and a global package directory breaks version managers
-unset PREFIX
-
-# Support Homebrew on M1
-HOMEBREW_M1_BIN=/opt/homebrew/bin
-if [[ -d $HOMEBREW_M1_BIN && ! $PATH =~ $HOMEBREW_M1_BIN ]]; then
-  export PATH="$HOMEBREW_M1_BIN:$PATH"
-fi
-
-# Define NVM_DIR and source the nvm.sh setup script
-[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
-
-# Source nvm with '--no-use' and then `nvm use` to respect .nvmrc
-# See: https://github.com/nvm-sh/nvm/issues/2053
-if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
-  # shellcheck source=/dev/null
-  . "$HOME/.nvm/nvm.sh" --no-use
-  nvm use 2> /dev/null || nvm use default
-elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
-  # shellcheck source=/dev/null
-  . "$(brew --prefix nvm)/nvm.sh" --no-use
-  nvm use 2> /dev/null || nvm use default
-fi
-
-# Set up the nodenv node version manager if present
-if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
-  eval "$("$HOME/.nodenv/bin/nodenv" init -)"
-elif [[ -x "$(command -v brew)" && -x "$(brew --prefix nodenv)/bin/nodenv" ]]; then
-  eval "$("$(brew --prefix nodenv)/bin/nodenv" init -)"
-fi
-
-# Set up the ndenv of anyenv if preset
-if [[ ! -x node && -d ${HOME}/.anyenv/bin ]]; then
-  export PATH=${HOME}/.anyenv/bin:${PATH}
-  if [[ "$(anyenv envs | grep -c ndenv )" -eq 1 ]]; then
-    eval "$(anyenv init -)"
-  fi
-fi
-
-# Set up asdf-vm if present
-if [[ -f "$HOME/.asdf/asdf.sh" ]]; then
-  # shellcheck source=/dev/null
-  . "$HOME/.asdf/asdf.sh"
-elif [[ -x "$(command -v brew)" && -f "$(brew --prefix asdf)/asdf.sh" ]]; then
-  # shellcheck source=/dev/null
-  . "$(brew --prefix asdf)/asdf.sh"
-fi
diff --git a/node_modules/react-native/scripts/react-native-xcode.sh b/node_modules/react-native/scripts/react-native-xcode.sh
index 3ef9a71..304a5dc 100755
--- a/node_modules/react-native/scripts/react-native-xcode.sh
+++ b/node_modules/react-native/scripts/react-native-xcode.sh
@@ -79,9 +79,7 @@ if [[ $DEV != true && ! -f "$ENTRY_FILE" ]]; then
   exit 2
 fi
 
-# Find path to Node
-# shellcheck source=/dev/null
-source "$REACT_NATIVE_DIR/scripts/find-node.sh"
+NODE_BINARY="$(command -v node)"
 
 # check and assign NODE_BINARY env
 # shellcheck source=/dev/null
diff --git a/node_modules/react-native/scripts/react_native_pods.rb b/node_modules/react-native/scripts/react_native_pods.rb
index 1b8a078..d65c9ca 100644
--- a/node_modules/react-native/scripts/react_native_pods.rb
+++ b/node_modules/react-native/scripts/react_native_pods.rb
@@ -289,8 +289,6 @@ else
 fi
 
 find_node () {
-  source "$RN_DIR/scripts/find-node.sh"
-
   NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}"
   if [ -z "$NODE_BINARY" ]; then
     echo "error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
  • Attempt to upload sourcemaps by compiling a release, yarn && npx react-native run-ios --configuration Release --device
  • See build errors in build.log below
  • Remove the patch from patches/ and run yarn && npx react-native run-ios --configuration Release --device
  • Observe that sentry sourcemaps now upload successfully and nothing noteworthy is in build.log

Alternatively, one could perhaps try initializing a new project of v0.69.0-rc.x and attempt to upload sourcemaps - I imagine that would suffer the same issue.

Expected Result

Source maps upload.

Actual Result

Source maps do not upload.

Here is the output of build.log after updating the "Bundle React Native code and images" to be as follows:

shellScript = "exec > \"${PROJECT_DIR}/../build.log\" 2>&1\nset -o pipefail\nset -e\nexport SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nset -e\n\nexport NODE_BINARY=node\nexport PROJECT_ROOT=$PWD/..\n../../../node_modules/@sentry/cli/bin/sentry-cli --log-level trace react-native xcode ../../../node_modules/react-native/scripts/react-native-xcode.sh\n";

2022-06-03T23:58:27.9401520Z $ cat build.log
2022-06-03T23:58:27.9766460Z   DEBUG   2022-06-03 23:44:56.048046 +00:00 sentry-cli version: 1.74.4, platform: "darwin", architecture: "x86_64"
2022-06-03T23:58:27.9769080Z   INFO    2022-06-03 23:44:56.049030 +00:00 sentry-cli was invoked with the following command line: "/Users/runner/work/1fb-consumers/1fb-consumers/node_modules/@sentry/cli/sentry-cli" "--log-level" "trace" "react-native" "xcode" "../../../node_modules/react-native/scripts/react-native-xcode.sh"
2022-06-03T23:58:27.9771980Z   INFO    2022-06-03 23:44:56.050532 +00:00 Issuing a command for Organization: bhw-iv Project: 1fb-mobile
2022-06-03T23:58:27.9777230Z   INFO    2022-06-03 23:44:56.050577 +00:00 Using react-native build script at /Users/runner/work/1fb-consumers/1fb-consumers/packages/mobile/ios
2022-06-03T23:58:27.9779070Z   INFO    2022-06-03 23:44:56.050607 +00:00 Parsing Info.plist
2022-06-03T23:58:27.9780660Z   INFO    2022-06-03 23:44:56.053159 +00:00 Parse result from Info.plist: InfoPlist { name: "mobilefscm", bundle_id: "com.onefbusa.mobilefscm", version: "2.100", build: "209" }
2022-06-03T23:58:27.9783670Z   INFO    2022-06-03 23:44:56.053438 +00:00 Using node interpreter 'node'
2022-06-03T23:58:27.9786200Z + DEST=/Users/runner/Library/Developer/Xcode/DerivedData/OneFBUSAMobile-bakroiuxclyihkbzeycaloiplmnz/Build/Intermediates.noindex/ArchiveIntermediates/OneFBUSAMobile/BuildProductsPath/Release-iphoneos/mobilefscm.app
2022-06-03T23:58:27.9787610Z + [[ Release = *Debug* ]]
2022-06-03T23:58:27.9789400Z + [[ -n '' ]]
2022-06-03T23:58:27.9792770Z + case "$CONFIGURATION" in
2022-06-03T23:58:27.9793510Z + DEV=false
2022-06-03T23:58:27.9796770Z +++ dirname /Users/runner/work/1fb-consumers/1fb-consumers/node_modules/react-native/scripts/react-native-xcode.sh
2022-06-03T23:58:27.9801050Z ++ cd /Users/runner/work/1fb-consumers/1fb-consumers/node_modules/react-native/scripts/..
2022-06-03T23:58:27.9803030Z ++ pwd
2022-06-03T23:58:27.9804150Z + REACT_NATIVE_DIR=/Users/runner/work/1fb-consumers/1fb-consumers/node_modules/react-native
2022-06-03T23:58:27.9805680Z + PROJECT_ROOT=/Users/runner/work/1fb-consumers/1fb-consumers/packages/mobile/ios/..
2022-06-03T23:58:27.9806620Z + cd /Users/runner/work/1fb-consumers/1fb-consumers/packages/mobile/ios/..
2022-06-03T23:58:27.9807420Z + [[ -n '' ]]
2022-06-03T23:58:27.9808180Z + [[ -s index.ios.js ]]
2022-06-03T23:58:27.9809060Z + ENTRY_FILE=index.js
2022-06-03T23:58:27.9809700Z + [[ false != true ]]
2022-06-03T23:58:27.9810470Z + [[ ! -f index.js ]]
2022-06-03T23:58:27.9811340Z ++ command -v node
2022-06-03T23:58:27.9812510Z + NODE_BINARY=/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/yarn--1654298910481-0.4004905287815401/node
2022-06-03T23:58:27.9813750Z + source /Users/runner/work/1fb-consumers/1fb-consumers/node_modules/react-native/scripts/node-binary.sh
2022-06-03T23:58:27.9814970Z ++ '[' -z /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/yarn--1654298910481-0.4004905287815401/node ']'
2022-06-03T23:58:27.9817660Z ++ type /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/yarn--1654298910481-0.4004905287815401/node
2022-06-03T23:58:27.9819260Z + '[' -z '' ']'
2022-06-03T23:58:27.9824670Z + HERMES_CLI_PATH=/Users/runner/work/1fb-consumers/1fb-consumers/packages/mobile/ios/Pods/hermes-engine/destroot/bin/hermesc
2022-06-03T23:58:27.9826160Z + [[ -z '' ]]
2022-06-03T23:58:27.9827360Z + [[ -f /Users/runner/work/1fb-consumers/1fb-consumers/packages/mobile/ios/Pods/hermes-engine/destroot/bin/hermesc ]]
2022-06-03T23:58:27.9829940Z + [[ '' == true ]]
2022-06-03T23:58:27.9831220Z + '[' -z '' ']'
2022-06-03T23:58:27.9832180Z + export NODE_ARGS=
2022-06-03T23:58:27.9832850Z + NODE_ARGS=
2022-06-03T23:58:27.9835750Z + '[' -z '' ']'
2022-06-03T23:58:27.9836610Z + export CLI_PATH=/Users/runner/work/1fb-consumers/1fb-consumers/node_modules/react-native/cli.js
2022-06-03T23:58:27.9837490Z + CLI_PATH=/Users/runner/work/1fb-consumers/1fb-consumers/node_modules/react-native/cli.js
2022-06-03T23:58:27.9838210Z + '[' -z '' ']'
2022-06-03T23:58:27.9838580Z + BUNDLE_COMMAND=bundle
2022-06-03T23:58:27.9839030Z + '[' -z '' ']'
2022-06-03T23:58:27.9839920Z + COMPOSE_SOURCEMAP_PATH=/Users/runner/work/1fb-consumers/1fb-consumers/node_modules/react-native/scripts/compose-source-maps.js
2022-06-03T23:58:27.9840840Z + [[ -z '' ]]
2022-06-03T23:58:27.9842720Z + CONFIG_ARG=
2022-06-03T23:58:27.9844040Z + BUNDLE_FILE=/Users/runner/Library/Developer/Xcode/DerivedData/OneFBUSAMobile-bakroiuxclyihkbzeycaloiplmnz/Build/Intermediates.noindex/ArchiveIntermediates/OneFBUSAMobile/BuildProductsPath/Release-iphoneos/main.jsbundle
2022-06-03T23:58:27.9844920Z + EXTRA_ARGS=
2022-06-03T23:58:27.9845280Z + case "$PLATFORM_NAME" in
2022-06-03T23:58:27.9845630Z + BUNDLE_PLATFORM=ios
2022-06-03T23:58:27.9846250Z + '[' '' = YES ']'
2022-06-03T23:58:27.9846700Z + EMIT_SOURCEMAP=
2022-06-03T23:58:27.9847110Z + [[ ! -z '' ]]
2022-06-03T23:58:27.9847500Z + PACKAGER_SOURCEMAP_FILE=
2022-06-03T23:58:27.9848170Z + [[ '' == true ]]
2022-06-03T23:58:27.9848590Z + [[ '' == true ]]
2022-06-03T23:58:27.9854290Z + /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/yarn--1654298910481-0.4004905287815401/node /Users/runner/work/1fb-consumers/1fb-consumers/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/OneFBUSAMobile-bakroiuxclyihkbzeycaloiplmnz/Build/Intermediates.noindex/ArchiveIntermediates/OneFBUSAMobile/BuildProductsPath/Release-iphoneos/main.jsbundle --assets-dest /Users/runner/Library/Developer/Xcode/DerivedData/OneFBUSAMobile-bakroiuxclyihkbzeycaloiplmnz/Build/Intermediates.noindex/ArchiveIntermediates/OneFBUSAMobile/BuildProductsPath/Release-iphoneos/mobilefscm.app --sourcemap-output /Users/runner/Library/Developer/Xcode/DerivedData/OneFBUSAMobile-bakroiuxclyihkbzeycaloiplmnz/Build/Intermediates.noindex/ArchiveIntermediates/OneFBUSAMobile/IntermediateBuildFilesPath/OneFBUSAMobile.build/Release-iphoneos/OneFBUSAMobile.build/DerivedSources/main.jsbundle.map
2022-06-03T23:58:27.9856430Z warning: the transform cache was reset.
2022-06-03T23:58:27.9857310Z                     Welcome to Metro!
2022-06-03T23:58:27.9858030Z               Fast - Scalable - Integrated
2022-06-03T23:58:27.9858740Z 
2022-06-03T23:58:27.9858820Z 
2022-06-03T23:58:27.9860360Z info Writing bundle output to:, /Users/runner/Library/Developer/Xcode/DerivedData/OneFBUSAMobile-bakroiuxclyihkbzeycaloiplmnz/Build/Intermediates.noindex/ArchiveIntermediates/OneFBUSAMobile/BuildProductsPath/Release-iphoneos/main.jsbundle
2022-06-03T23:58:27.9866440Z info Writing sourcemap output to:, /Users/runner/Library/Developer/Xcode/DerivedData/OneFBUSAMobile-bakroiuxclyihkbzeycaloiplmnz/Build/Intermediates.noindex/ArchiveIntermediates/OneFBUSAMobile/IntermediateBuildFilesPath/OneFBUSAMobile.build/Release-iphoneos/OneFBUSAMobile.build/DerivedSources/main.jsbundle.map
2022-06-03T23:58:27.9867340Z info Done writing bundle output
2022-06-03T23:58:27.9867920Z info Done writing sourcemap output
2022-06-03T23:58:27.9868850Z info Copying 160 asset files
2022-06-03T23:58:27.9869240Z info Done copying assets
2022-06-03T23:58:27.9870380Z + [[ '' != true ]]
2022-06-03T23:58:27.9872700Z + cp /Users/runner/Library/Developer/Xcode/DerivedData/OneFBUSAMobile-bakroiuxclyihkbzeycaloiplmnz/Build/Intermediates.noindex/ArchiveIntermediates/OneFBUSAMobile/BuildProductsPath/Release-iphoneos/main.jsbundle /Users/runner/Library/Developer/Xcode/DerivedData/OneFBUSAMobile-bakroiuxclyihkbzeycaloiplmnz/Build/Intermediates.noindex/ArchiveIntermediates/OneFBUSAMobile/BuildProductsPath/Release-iphoneos/mobilefscm.app/
2022-06-03T23:58:27.9874690Z + BUNDLE_FILE=/Users/runner/Library/Developer/Xcode/DerivedData/OneFBUSAMobile-bakroiuxclyihkbzeycaloiplmnz/Build/Intermediates.noindex/ArchiveIntermediates/OneFBUSAMobile/BuildProductsPath/Release-iphoneos/mobilefscm.app/main.jsbundle
2022-06-03T23:58:27.9875390Z + [[ false != true ]]
2022-06-03T23:58:27.9877320Z + [[ ! -f /Users/runner/Library/Developer/Xcode/DerivedData/OneFBUSAMobile-bakroiuxclyihkbzeycaloiplmnz/Build/Intermediates.noindex/ArchiveIntermediates/OneFBUSAMobile/BuildProductsPath/Release-iphoneos/mobilefscm.app/main.jsbundle ]]
2022-06-03T23:58:27.9879040Z thread 'unnamed' panicked at 'File /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/b558b438-8d1c-4ec2-84f7-278b306fc2f3 doesn't contain a valid JSON data.': src/commands/react_native_xcode.rs:247
2022-06-03T23:58:27.9879640Z 
2022-06-03T23:58:27.9879870Z    0: backtrace::backtrace::trace
2022-06-03T23:58:27.9880080Z 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions