reactotron: iOS Release Build app crash on real device
Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Error: invalid host, js engine: hermes', reason: 'Unhandled JS Exception: Error: invalid host, js engine: hermes
App crashing in ios release mode. Refer for detail: https://github.com/facebook/hermes/issues/1228
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Reactions: 7
- Comments: 27 (3 by maintainers)
Commits related to this issue
- Use require instead of import to fix crash. - https://github.com/infinitered/reactotron/issues/1398#issuecomment-1899058678 — committed to coopcycle/coopcycle-app by alexsegura 3 months ago
- chore(docs): Update code snippet using require instead of import. (#1468) Since #1398 we know that `require()` should be used, I updated the code snippet so that people can copy/paste working code. — committed to infinitered/reactotron by alexsegura 3 months ago
Reactotron should not be loaded in production. Read more about why here. https://docs.infinite.red/reactotron/tips/#running-in-production
Consider adding eslint-plugin-reactotron to your project to help ensure that any reactotron calls are getting hidden behind a
__DEV__flag.Trouble shooting checklist:
__DEV__flagrequire('ReactotronConfig.ts')instead ofimport('ReactotronConfig')becauseimportis hoisted outside of__DEV__blocks.✅ Closing this issue since below things are working properly, just follow below and then delete nodemodules,lock files, pods etc and reinstall again:
Downgrading
reactotron-react-nativeto 5.0.3 and removinghostfrom the configuration worked for us.Same here. In my case only on iOS Release Mode
The problem started to happen in version 5.0.4 of reactotron-react-native. Using version 5.0.3 the crash does not occur. Comparing the versions, it can be seen that the getHost routine in the file /reactotron-react-native/src/reactotron-react-native.ts uses a simplified version, which works for Expo applications, but in iOS builds in release mode this new version uses the URI of the embedded bundle.
Example: using the code NativeModules?.SourceCode?.getConstants().scriptURL in release mode you get something like file:///private/var/containers/Bundle/Application/38A07257-A8E8-4565-BBE6-6B874A82A47B/app_name.app /main.jsbundle The new getHost routine will extract “private” and will try to use it as a host, which generates the “invalid host” exception
@Ajmal0197
Your solution works. Thank you for saving my day
This is what work for us with the latest version
5.1.3:@pokey the real issue is caused by running Reactotron in production, upgrading to 5.0.5 seemed highlight this issue for some users.
I put together a checklist here for how to ensure that Reactotron is not getting loaded in your app and a helpful linting rule to prevent it in the future: https://github.com/infinitered/reactotron/issues/1398#issuecomment-1899058678
After some tinkering and researching other projects, I finally figured out a configuration that’s working for me using Redux Toolkit v2:
I hope that works for you too! I updated my tsconfig compilerOptions to include
"module": "Node16", "moduleResolution": "Node16", "esModuleInterop": true, but couldn’t get Reactotron to come insto store.ts with a type other thanany.Downgrade
reactotron-react-nativeto 5.0.3 worked for me too. I cleared node_modules and installed pods again. I usehostconfiguration and didn’t have to remove it. I don’t havereactotron-reduxSame here, and this problem started today, the lib release was about 20 hours ago…
I had to remove node_modules, clear metro and XCode cache to work locally after downgrade