react-native-exception-handler icon indicating copy to clipboard operation
react-native-exception-handler copied to clipboard

setJSExceptionHandler is not caching the fatal error for android

Open piyushdesuvit opened this issue 6 years ago • 14 comments
trafficstars

image

const errorHandler = (e, isFatal) => {
    if (isFatal) {
        Alert.alert(
            'Unexpected error occurred',
            `Error: ${(isFatal) ? 'Fatal:' : ''} ${e.name} ${e.message}   Please close the app and start again.`, [{
                text: 'OK',
            }]
        );
    } else {
        
    }
};

setJSExceptionHandler((error, isFatal) => {
    console.log('setJSExceptionHandler-->', error, isFatal);
    errorHandler(error, isFatal);
}, true);

for error showing the componentWillUnmount method fatal error it is showing undefined

react-native version "^0.59.5", "react": "^16.8.6", "react-native-exception-handler": "^2.10.7",

piyushdesuvit avatar May 09 '19 13:05 piyushdesuvit

same issue here Android 8

cinder92 avatar May 11 '19 18:05 cinder92

same here android 7

a1lu avatar May 29 '19 06:05 a1lu

Does it not catch any errors ? I mean does it work without the isFatal check ?

const errorHandler = (e, isFatal) => {
    Alert.alert(
            'Unexpected error occurred'
        );
};

Also it would be really helpful if anyone can give a link to a repo where this issue occurs ?

a7ul avatar May 29 '19 07:05 a7ul

Nope is not working. My code: setJSExceptionHandler(errorHandler, true);

in constructor of main class. I still get the red ReferenceError screen for a undefined test() call

a1lu avatar Jun 14 '19 08:06 a1lu

Is anyone working on this? Can confirm the handler is not functioning properly.

mstankov avatar Jun 14 '19 14:06 mstankov

@master-atul @piyushdesuvit I'm facing the same issue n both android and ios. The exception alert only displays in the beginning if declare the setNativeExceptionHandler method in iOS

ManigandanRaamanathan avatar Jun 17 '19 04:06 ManigandanRaamanathan

Can someone create a simple react native app repo with reproducible error ? So that we can take a look at it. @ManigandanRaamanathan @mstankov

a7ul avatar Jun 17 '19 10:06 a7ul

@master-atul I'll get you the snack example code tomorrow

ManigandanRaamanathan avatar Jun 17 '19 15:06 ManigandanRaamanathan

Is anybody find a solution about this please ?

samisamsam avatar Sep 09 '19 21:09 samisamsam

I have got the same issue here, both (error, isFatal) are undefined. Anyone working on this ?

vinchentsoKN avatar Sep 18 '19 11:09 vinchentsoKN

i am still getting the same result. did anybody solve this problem? RN version 0.60.2 and i used the pod install to link the library.

This is what the library returns Screen Shot 2020-11-11 at 14 12 44

The code that i used Screen Shot 2020-11-11 at 14 13 30

donmezemre avatar Nov 11 '20 11:11 donmezemre

Same here:

const jsErrorHandler = (e, isFatal) => {
  console.warn(JSON.stringify({ e, isFatal })));
};
setJSExceptionHandler(jsErrorHandler, true);
{"e":"the componentWillUnmount method","isFatal":false}

alessandroraffa avatar Nov 13 '20 16:11 alessandroraffa

Same here. I think I'm just going to use this:

ErrorUtils.setGlobalHandler((error, isFatal) => {
  console.log('fug!', error);
});

Jarzka avatar Jun 03 '21 08:06 Jarzka

+1 andriod still crashes directly. but ios works fine without a crash (just not responsive).

dongdyang avatar Sep 22 '21 04:09 dongdyang