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

Js exeception not caught in dev mode until first render #52

Open
dowmeister opened this issue May 2, 2018 · 4 comments
Open

Js exeception not caught in dev mode until first render #52

dowmeister opened this issue May 2, 2018 · 4 comments

Comments

@dowmeister
Copy link

dowmeister commented May 2, 2018

Hi,

i'm trying to integrate this module

In index.js (main entrypoint)

import {
    AppRegistry
} from 'react-native';
import App from './App';

import {
    Alert
} from 'react-native';
import {
    setJSExceptionHandler,
    getJSExceptionHandler
} from 'react-native-exception-handler';
import {
    setNativeExceptionHandler
} from 'react-native-exception-handler';

const errorHandler = (e, isFatal) => {

    console.log('------------------- JS HANDLER ------------------');
console.log('------------------- CUSTOM JS HANDLER ------------------');
    console.log(error);

    if (isFatal) {
        Alert.alert(
            'Unexpected error occurred',
            `
          Error: ${(isFatal) ? 'Fatal:' : ''} ${e.name} ${e.message}
  
          We will need to restart the app.
          `, [{
                text: 'Restart',
                onPress: () => {
                    //RNRestart.Restart();
                }
            }]
        );
    } else {
        console.log(e); // So that we can see it in the ADB logs in case of Android if needed
    }
};

const setNativeHandler = (exceptionString) => {

    console.log('------------------- NATIVE HANDLER ------------------');
    console.log(exceptionString);
};

console.log('------------------- JS HANDLER ------------------');
console.log('Entering exception handling');

setJSExceptionHandler(errorHandler, true);

setNativeExceptionHandler(setNativeHandler, false);

AppRegistry.registerComponent('TruckyV2', () => App);

In adb log i see

------------------- JS HANDLER ------------------ Entering exception handling

Don't see ------------------- CUSTOM JS HANDLER ------------------

In Home.js constructor (called from App), i've added this.test() to force fire error, continue to see the RN default red screeen

screenshot_1525254292

What's wrong?

"react": "^16.3.1",
"react-native": "^0.55.3",
"react-native-exception-handler": "^2.7.5",

Thanks

@a7ul
Copy link
Owner

a7ul commented May 2, 2018

Hi @shardick Yes, The exception handler doesnt catch the error on first render. Its an issue being tracked here #36. The issue is that the js exception handler module doesn't seem to fire before first render.

The issue occurs only till first render of the app.

You can try moving the this.test() call to a button click maybe to test it.

In the meanwhile I ll mark this as a bug and track it here.

@a7ul a7ul changed the title Js exeception not caught in dev mode Js exeception not caught in dev mode until first render May 2, 2018
@dowmeister
Copy link
Author

Thanks @master-atul

Confirmed, it works on next interaction

screenshot_1525264285

@aks1994
Copy link

aks1994 commented Feb 7, 2019

Hello, is there any fix for this planned?

@a7ul
Copy link
Owner

a7ul commented Feb 7, 2019

Not really at the moment. I am not sure how to solve this.

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

No branches or pull requests

3 participants