React-native: Application crashing only in release mode, how to debug this kind of problem?

Created on 3 Apr 2018  路  10Comments  路  Source: facebook/react-native

Environment


Environment:
OS: macOS High Sierra 10.13
Node: 9.10.1
Yarn: Not Found
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: ^16.3.0 => 16.3.0
react-native: ^0.55.0 => 0.55.0

Steps to Reproduce


Follow the steps in https://facebook.github.io/react-native/docs/running-on-device.html, Building your app for production.
Run a release build. Open Xcode. Go to edit schemes. Change the Run build configuration from Debug to Release. Or you can run it from terminal: react-native run-ios --configuration Release

Expected Behavior


JS bundle completes launch and app doesn't crash.

Actual Behavior


App crashes when the JS bundle loads. Here is the crash log:

*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Cannot call a class as a function', reason: 'Unhandled JS Exception: Cannot call a class as a function, stack: classCallCheck@11:648 t@306:876 run@279:617 runApplication@279:2046 value@18:3471 <unknown>@18:956 value@18:2898 value@18:928

My application works fine on release for Android, and also works fine in debug mode on iOS, the problem only appears on iOS release mode. How should i debug problems in release mode? I Tried to reident and look at the lines of code suggested on the error message in the main.jsbundle, but i haven't been able to find the source of the problem anyway.

I tried everything i found on the issues #18647 #16567 and in similar issues. My application code is huge so i cant check every react class to find the problem(although i tried). Should i try to reinstall all my dependencies from zero until i find what is causing the problem? It seems like react native have absolutely no support for this kind of release bugs problem from the other issues i have seen.

For Stack Overflow Locked

Most helpful comment

after 5 days looking for the issue i found out the problem was that my index.ios.js was calling my main class like this
AppRegistry.registerComponent('App', App);
when it actually should have been like this
AppRegistry.registerComponent('App', () => App);

For anyone that got stuck in release bugs like me try installing the haul library https://github.com/callstack/haul, it still has many bugs, but it gives much better error messages then the react native core. Debugging this problem would be impossible if i had not found haul.

I also had to use haul to bundle the javascript without minification to be able to find about the bug.

All 10 comments

Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.55?

Thank you for your contributions.

after 5 days looking for the issue i found out the problem was that my index.ios.js was calling my main class like this
AppRegistry.registerComponent('App', App);
when it actually should have been like this
AppRegistry.registerComponent('App', () => App);

For anyone that got stuck in release bugs like me try installing the haul library https://github.com/callstack/haul, it still has many bugs, but it gives much better error messages then the react native core. Debugging this problem would be impossible if i had not found haul.

I also had to use haul to bundle the javascript without minification to be able to find about the bug.

@vzaffalon how to make a release build without minification please ? !

my app also running so good on debug mode but crashes when i make release. can not figure out where is the error. how to make a release build without minifaction so i can know the exact error ? !
i also installed haul.

thank you in advance .

use Haul bundle --minify false before running the application, after i found the error i had to uninstal haul because it was causing integration bugs with realm library, suggest you do the same

@vzaffalon

thank you for your reply i really apperciate.

i did that and now the error message is different

WARNING: Logging before InitGoogleLogging() is written to STDERR

i have no clue what is that.

i also had to remove haul cause it's giving lots of other errors while using redux saga while the debug mode is just working fine.

i also made new question on stack maybe someone can help

https://stackoverflow.com/questions/49815999/app-release-crashes-t-is-not-a-function

thank u

Welcome to the react native world where you have to waste half of your dev time trying to guess what is causing the magical bug, and you dont have any good information logs to do so.

You can use console.error, will show in Xcode Console

It only crash in release. Debug mode is fine.

It only crash in release. Debug mode is fine.

++

Destructuring of an empty object may be the reason,
ex:
let {}=this.props.result

Was this page helpful?
0 / 5 - 0 ratings