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

failure to generate bundle on EAS Build #187

Closed
giautm opened this issue May 9, 2021 · 31 comments
Closed

failure to generate bundle on EAS Build #187

giautm opened this issue May 9, 2021 · 31 comments

Comments

@giautm
Copy link
Contributor

giautm commented May 9, 2021

Hi, I just trying to use sentry-expo plugin on EAS Build. I have config correct sentry-expo, but the build was failure with following errors:

+ /Users/expo/workingdir/build/node_modules/@sentry/cli/sentry-cli /Users/expo/workingdir/build/node_modules/react-native/cli.js bundle --entry-file ./__generated__/AppEntry.js --platform ios --dev false --reset-cache --bundle-output /Users/expo/Library/Developer/Xcode/DerivedData/XXXXXXXXXX/Build/Intermediates.noindex/ArchiveIntermediates/XXXXXXXXXX/BuildProductsPath/Release-iphoneos/XXXXXXXXXX.app/main.jsbundle --assets-dest /Users/expo/Library/Developer/Xcode/DerivedData/XXXXXXXXXX/Build/Intermediates.noindex/ArchiveIntermediates/XXXXXXXXXX/BuildProductsPath/Release-iphoneos/XXXXXXXXXX.app --sourcemap-output /Users/expo/Library/Developer/Xcode/DerivedData/XXXXXXXXXX/Build/Intermediates.noindex/ArchiveIntermediates/XXXXXXXXXX/IntermediateBuildFilesPath/XXXXXXXXXX.build/Release-iphoneos/XXXXXXXXXX.build/DerivedSources/main.jsbundle.map
error Invalid platform "ios" selected.
info Available platforms are: "native". If you are trying to bundle for an out-of-tree platform, it may not be installed.
error Bundling failed. Run CLI with --verbose flag for more details.
@giautm
Copy link
Contributor Author

giautm commented May 10, 2021

Hey @cruzach, Can you take a look at this issue? I think issue related to withSentryIOS.ts script.

@cruzach
Copy link
Contributor

cruzach commented May 11, 2021

@giautm I tested an iOS build just now with the following in app.json, and it worked and uploaded sourcemaps without a problem:

    "plugins": ["sentry-expo"],
    "hooks": {
      "postPublish": [
        {
          "file": "sentry-expo/upload-sourcemaps",
          "config": {
            "organization": "myorg",
            "project": "sentrytest",
            "authToken": "myauthtoken"
          }
        }
      ]
    }

Please provide all the information needed to reproduce the issue

@giautm
Copy link
Contributor Author

giautm commented May 11, 2021

Hey, I can send the build ID that I face with the issue. Can you view it instead?

The build id is 2aa2be6c-1ee5-4036-b31b-14313ebc2e70

@cruzach
Copy link
Contributor

cruzach commented May 11, 2021

I need to know your app configuration as well. You should try to reproduce this issue in a blank project to make sure it is a bug with sentry-expo, and not just a bug in your own project

@giautm
Copy link
Contributor Author

giautm commented May 11, 2021

It is hard to reproduce right because my project is a part of a mono repo. This is a diff between before & after I apply the sentry-expo plugin.
https://gist.github.com/giautm/9a6403cc46dceaa143269ff2d4695f5f/revisions#diff-6eb5aa2af122281945d8d42cc285a04af319c927fec0b2e03ce47987c39985a2

the config is mostly the same.

    "plugins": ["sentry-expo"],
    "hooks": {
      "postPublish": [
        {
          "config": {
            "authToken": "xxxxx",
            "organization": "sentry",
            "project": "freelancer",
            "url": "https://sentry-aws.aaaaaaa.xyz"
          },
          "file": "sentry-expo/upload-sourcemaps"
        },

@cruzach
Copy link
Contributor

cruzach commented May 11, 2021

hm, that doesn't look like the diff of the sentry-expo plugin... you can see the expected modifications here- https://github.com/expo/sentry-expo/blob/master/plugin/src/withSentryIOS.ts

@giautm
Copy link
Contributor Author

giautm commented May 13, 2021

Hey @cruzach, This is my reproduce repo: giautm/eas-monorepo-example@main...giautm:issue/sentry-expo

This is the build ID with error: 8b3ad330-7beb-4ade-bf59-4fb75cdae2c7. Can you take a look?

+ CONFIG_ARG=
+ BUNDLE_FILE=/Users/expo/Library/Developer/Xcode/DerivedData/easmonorepoappmanaged-aprsyiyhsnipjoecftblhjhrythe/Build/Intermediates.noindex/ArchiveIntermediates/easmonorepoappmanaged/BuildProductsPath/Release-iphoneos/sentry-expo.app/main.jsbundle
+ /Users/expo/workingdir/build/node_modules/@sentry/cli/sentry-cli /Users/expo/workingdir/build/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/expo/Library/Developer/Xcode/DerivedData/easmonorepoappmanaged-aprsyiyhsnipjoecftblhjhrythe/Build/Intermediates.noindex/ArchiveIntermediates/easmonorepoappmanaged/BuildProductsPath/Release-iphoneos/sentry-expo.app/main.jsbundle --assets-dest /Users/expo/Library/Developer/Xcode/DerivedData/easmonorepoappmanaged-aprsyiyhsnipjoecftblhjhrythe/Build/Intermediates.noindex/ArchiveIntermediates/easmonorepoappmanaged/BuildProductsPath/Release-iphoneos/sentry-expo.app --sourcemap-output /Users/expo/Library/Developer/Xcode/DerivedData/easmonorepoappmanaged-aprsyiyhsnipjoecftblhjhrythe/Build/Intermediates.noindex/ArchiveIntermediates/easmonorepoappmanaged/IntermediateBuildFilesPath/easmonorepoappmanaged.build/Release-iphoneos/easmonorepoappmanaged.build/DerivedSources/main.jsbundle.map
error Invalid platform "ios" selected.
info Available platforms are: "native". If you are trying to bundle for an out-of-tree platform, it may not be installed.
error Bundling failed. Run CLI with --verbose flag for more details.
Error: Bundling failed
    at buildBundle (/Users/expo/workingdir/build/node_modules/@react-native-community/cli/build/commands/bundle/buildBundle.js:85:11)
    at async Command.handleAction (/Users/expo/workingdir/build/node_modules/@react-native-community/cli/build/index.js:186:9)

PS: My original project use SDKv41, but this error also happened on SDKv40. So, I don't think it's related.

@cruzach
Copy link
Contributor

cruzach commented May 13, 2021

@giautm this might be a relevant issue for you to look at - react-native-community/cli#656

@giautm
Copy link
Contributor Author

giautm commented May 13, 2021

Hi, I found the fix. Put react-native in workspace package.json will fix the issue; see the diff

{
  "dependencies": {
    "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz"
  },
}

The XCode log will be changed as:

  + case "$CONFIGURATION" in
  + DEV=false
- +++ dirname /Users/expo/workingdir/build/node_modules/react-native/scripts/react-native-xcode.sh
+ +++ dirname /Users/expo/workingdir/build/apps/managed/node_modules/react-native/scripts/react-native-xcode.sh
- ++ cd /Users/expo/workingdir/build/node_modules/react-native/scripts/..
+ ++ cd /Users/expo/workingdir/build/apps/managed/node_modules/react-native/scripts/..
  ++ pwd
- + REACT_NATIVE_DIR=/Users/expo/workingdir/build/node_modules/react-native
+ + REACT_NATIVE_DIR=/Users/expo/workingdir/build/apps/managed/node_modules/react-native
- + PROJECT_ROOT=/Users/expo/workingdir/build/node_modules/react-native/../..
+ + PROJECT_ROOT=/Users/expo/workingdir/build/apps/managed/node_modules/react-native/../..
- + cd /Users/expo/workingdir/build/node_modules/react-native/../..
+ + cd /Users/expo/workingdir/build/apps/managed/node_modules/react-native/../..
  + '[' -z /Users/expo/.nvm ']'
  + [[ -n '' ]]
  + [[ -s index.ios.js ]]

But, I don't like the solution. I have tried to set PROJECT_ROOT to $PROJECT_DIR/.. with eas.json, but It doesn't work.

        "env": {
          "PROJECT_ROOT": "$PROJECT_DIR/.."
        }

It printed the plain text to the console as:

+ REACT_NATIVE_DIR=/Users/expo/workingdir/build/node_modules/react-native
+ PROJECT_ROOT='$PROJECT_DIR/..'
+ cd '$PROJECT_DIR/..'

@cruzach
Copy link
Contributor

cruzach commented May 13, 2021

This is an issue with monorepo setup, not with sentry-expo, so I'm going to close this issue

@giautm can you take a look at this monorepo example and try to proceed from there- https://github.com/byCedric/eas-monorepo-example? There's a couple different options for you to achieve what you're looking for here

I think that the env field can only be used for string values: https://docs.expo.io/build/eas-json/

@cruzach cruzach closed this as completed May 13, 2021
@giautm
Copy link
Contributor Author

giautm commented May 13, 2021

My reproduce repo is a fork of https://github.com/byCedric/eas-monorepo-example. ;)

I have faced other issues when trying to use EAS build with mono-repo. I have a little experience. ;)

@giautm
Copy link
Contributor Author

giautm commented May 15, 2021

Hey @cruzach, after I put react-native as a dependency in package.json, the build success but the app can't open.

Module AppRegistry is not a registered callable module (calling runApplication)

There is no error with the code, I try to rebuild the app many times with a single commit that adds react-native then it can't open.

{
  "dependencies": {
    "react-native": "https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz"
  },
}

Is there any way to fix the issue? 😢

@cruzach
Copy link
Contributor

cruzach commented May 15, 2021

@giautm that error message can be the result of a lot of different issues, you'll have to go through some manual debugging to investigate this further

@giautm
Copy link
Contributor Author

giautm commented May 15, 2021

@giautm that error message can be the result of a lot of different issues, you'll have to go through some manual debugging to investigate this further

Hey, I have try to debug. But on iOS, there is no error logged to the console.

I decide to remove this plugin and the fix (put "react-native" in "package.json"). I don't have enough time to find the root cause.

@parisholley
Copy link

i was able to reproduce this, there is some issue with post publish step in an EAS build, works fine (uploads code) using expo build:ios. Same behavior happens locally and remote, with simply a mainjs bundle missing but no error output from the postpublish step. i've tried symlinking all of the sentry modules (@sentry/....) but that didn't help.

https://github.com/parisholley/expo-bugs

@cruzach
Copy link
Contributor

cruzach commented Jul 24, 2021

@parisholley
Copy link

i did, it ONLY works if the plugin is defined, soon as you add the hook, the build breaks

@parisholley
Copy link

Because we no longer publish at build time, postPublish hooks in app.json will not be executed on build does not appear to be the case anymore. when i run expo prebuild, I still see a "Upload Debug Symbols to Sentry" step in my pbxproj

@byCedric
Copy link
Member

byCedric commented Jul 26, 2021

Please see the EAS monorepo example with Sentry and hooks configured: https://github.com/byCedric/eas-monorepo-example/tree/main/apps/with-sentry.

Android:

iOS:
still running atm, will update when its done

@parisholley
Copy link

reposting here: @byCedric it is very possible my error is iOS specific and your example doesn't have a working iOS test :) from what i can tell, the only difference between the example and the repo i provided is symlinks (which i've already tried linking sentry-expo and every @sentry/* dependency with no success)

@cruzach
Copy link
Contributor

cruzach commented Jul 26, 2021

when i run expo prebuild, I still see a "Upload Debug Symbols to Sentry" step in my pbxproj

Your sourcemaps are still uploaded, but it's done with Sentry's native build scripts, not with your post publish hook

@parisholley
Copy link

@byCedric were you able to confirm if this is an iOS specific issue? no rush on a fix, just need to know if I need to dig more :)

@byCedric
Copy link
Member

byCedric commented Jul 28, 2021

@byCedric were you able to confirm if this is an iOS specific issue? no rush on a fix, just need to know if I need to dig more :)

@parisholley It looks like it might be an issue with Sentry's CLI and finding the proper folder where the project is located in. This only seems to happen for monorepos though, only iOS, and only when you have a postpublish hook. I added an ios branch to the example I linked earlier, which should (temporarily) fix the issue.

If you can try that, it should work for your iOS builds 😄

@parisholley
Copy link

@byCedric that patch fixed eas remote build :) doesn't work for --local but I can live with that

@byCedric
Copy link
Member

Good to know! We are making progress on removing monorepo weirdness. We will definitely have something better for SDK 43!

@giautm
Copy link
Contributor Author

giautm commented Jul 28, 2021

Thanks @byCedric for the fix. I hope it soon plant to production.

@jereztech
Copy link

Same issue here, removing sentry-expo plugin working for me

@giautm
Copy link
Contributor Author

giautm commented Dec 28, 2021

@jereztech, please provide more information: sdk version, sentry-expo version. I have been build success with SDKv43 and v44

@jereztech
Copy link

hi @giautm I'm using sentry-expo@4.0.0 with SDKv43, in my case the error has been different sentry failed: resource not found (400) without further information. In my project the postPublish.project != expo.name, will it be something related to the name?

@giautm
Copy link
Contributor Author

giautm commented Dec 28, 2021

hi @giautm I'm using sentry-expo@4.0.0 with SDKv43, in my case the error has been different sentry failed: resource not found (400) without further information. In my project the postPublish.project != expo.name, will it be something related to the name?

I think it related to Sentry config, please double-check your API keys, project name, org on Sentry. It's not related to expo.name.

@jereztech
Copy link

I have copy/paste directly from Sentry, so this config is ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants