Comments (6)
Released 2.4.0 with the fix. Closing this issue.
Please upgrade and do react-native link again. @jiashenwang @hyb175
from react-native-exception-handler.
Steps to re-create:
- Use
react-native-cli
to create a new React Native project yarn add react-native-exception-handler react-native-mixpanel
- Install Mixpanel native library for ios following instruction from https://github.com/davodesign84/react-native-mixpanel#additional-step-for-ios
- Run app with
react-native run-ios
from react-native-exception-handler.
I have encountered exactly the same issue. I have applied the following patch to rename the constant to make the build passed.
diff --git a/node_modules/react-native-exception-handler/ios/ReactNativeExceptionHandler.m b/node_modules/react-native-exception-handler/ios/ReactNativeExceptionHandler.m
index 2b03ba7..6e75afa 100644
--- a/node_modules/react-native-exception-handler/ios/ReactNativeExceptionHandler.m
+++ b/node_modules/react-native-exception-handler/ios/ReactNativeExceptionHandler.m
@@ -2,13 +2,13 @@
// CONSTANTS
-NSString * const UncaughtExceptionHandlerSignalExceptionName = @"UncaughtExceptionHandlerSignalExceptionName";
-NSString * const UncaughtExceptionHandlerSignalKey = @"UncaughtExceptionHandlerSignalKey";
-NSString * const UncaughtExceptionHandlerAddressesKey = @"UncaughtExceptionHandlerAddressesKey";
-volatile int32_t UncaughtExceptionCount = 0;
-const int32_t UncaughtExceptionMaximum = 10;
-const NSInteger UncaughtExceptionHandlerSkipAddressCount = 4;
-const NSInteger UncaughtExceptionHandlerReportAddressCount = 5;
+NSString * const RNUncaughtExceptionHandlerSignalExceptionName = @"RNUncaughtExceptionHandlerSignalExceptionName";
+NSString * const RNUncaughtExceptionHandlerSignalKey = @"RNUncaughtExceptionHandlerSignalKey";
+NSString * const RNUncaughtExceptionHandlerAddressesKey = @"RNUncaughtExceptionHandlerAddressesKey";
+volatile int32_t RNUncaughtExceptionCount = 0;
+const int32_t RNUncaughtExceptionMaximum = 10;
+const NSInteger RNUncaughtExceptionHandlerSkipAddressCount = 4;
+const NSInteger RNUncaughtExceptionHandlerReportAddressCount = 5;
@implementation ReactNativeExceptionHandler
@@ -34,18 +34,18 @@ void (^jsErrorCallbackBlock)(NSException *exception, NSString *readeableExceptio
//variable that holds the default native error handler
void (^defaultNativeErrorCallbackBlock)(NSException *exception, NSString *readeableException) =
^(NSException *exception, NSString *readeableException){
-
+
UIAlertController* alert = [UIAlertController
alertControllerWithTitle:@"Unexpected error occured"
message:[NSString stringWithFormat:@"%@\n%@",
@"Appologies..The app will close now \nPlease restart the app\n",
readeableException]
preferredStyle:UIAlertControllerStyleAlert];
-
+
UIApplication* app = [UIApplication sharedApplication];
UIViewController * rootViewController = app.delegate.window.rootViewController;
[rootViewController presentViewController:alert animated:YES completion:nil];
-
+
[NSTimer scheduledTimerWithTimeInterval:5.0
target:[ReactNativeExceptionHandler class]
selector:@selector(releaseExceptionHold)
@@ -66,7 +66,7 @@ RCT_EXPORT_METHOD(setHandlerforNativeException:(RCTResponseSenderBlock)callback)
jsErrorCallbackBlock = ^(NSException *exception, NSString *readeableException){
callback(@[readeableException]);
};
-
+
NSSetUncaughtExceptionHandler(&HandleException);
signal(SIGABRT, SignalHandler);
signal(SIGILL, SignalHandler);
@@ -102,16 +102,16 @@ RCT_EXPORT_METHOD(setHandlerforNativeException:(RCTResponseSenderBlock)callback)
{
NSString * readeableError = [NSString stringWithFormat:NSLocalizedString(@"%@\n%@", nil),
[exception reason],
- [[exception userInfo] objectForKey:UncaughtExceptionHandlerAddressesKey]];
+ [[exception userInfo] objectForKey:RNUncaughtExceptionHandlerAddressesKey]];
dismissApp = false;
-
+
if(nativeErrorCallbackBlock != nil){
nativeErrorCallbackBlock(exception,readeableError);
}else{
defaultNativeErrorCallbackBlock(exception,readeableError);
}
jsErrorCallbackBlock(exception,readeableError);
-
+
CFRunLoopRef runLoop = CFRunLoopGetCurrent();
CFArrayRef allModes = CFRunLoopCopyAllModes(runLoop);
while (!dismissApp)
@@ -126,9 +126,9 @@ RCT_EXPORT_METHOD(setHandlerforNativeException:(RCTResponseSenderBlock)callback)
i++;
}
}
-
+
CFRelease(allModes);
-
+
NSSetUncaughtExceptionHandler(NULL);
signal(SIGABRT, SIG_DFL);
signal(SIGILL, SIG_DFL);
@@ -136,8 +136,8 @@ RCT_EXPORT_METHOD(setHandlerforNativeException:(RCTResponseSenderBlock)callback)
signal(SIGFPE, SIG_DFL);
signal(SIGBUS, SIG_DFL);
signal(SIGPIPE, SIG_DFL);
-
- kill(getpid(), [[[exception userInfo] objectForKey:UncaughtExceptionHandlerSignalKey] intValue]);
+
+ kill(getpid(), [[[exception userInfo] objectForKey:RNUncaughtExceptionHandlerSignalKey] intValue]);
}
@@ -148,19 +148,19 @@ RCT_EXPORT_METHOD(setHandlerforNativeException:(RCTResponseSenderBlock)callback)
void HandleException(NSException *exception)
{
- int32_t exceptionCount = OSAtomicIncrement32(&UncaughtExceptionCount);
- if (exceptionCount > UncaughtExceptionMaximum)
+ int32_t exceptionCount = OSAtomicIncrement32(&RNUncaughtExceptionCount);
+ if (exceptionCount > RNUncaughtExceptionMaximum)
{
return;
}
-
+
NSArray *callStack = [ReactNativeExceptionHandler backtrace];
NSMutableDictionary *userInfo =
[NSMutableDictionary dictionaryWithDictionary:[exception userInfo]];
[userInfo
setObject:callStack
- forKey:UncaughtExceptionHandlerAddressesKey];
-
+ forKey:RNUncaughtExceptionHandlerAddressesKey];
+
[[[ReactNativeExceptionHandler alloc] init]
performSelectorOnMainThread:@selector(handleException:)
withObject:
@@ -173,27 +173,27 @@ void HandleException(NSException *exception)
void SignalHandler(int signal)
{
- int32_t exceptionCount = OSAtomicIncrement32(&UncaughtExceptionCount);
- if (exceptionCount > UncaughtExceptionMaximum)
+ int32_t exceptionCount = OSAtomicIncrement32(&RNUncaughtExceptionCount);
+ if (exceptionCount > RNUncaughtExceptionMaximum)
{
return;
}
-
+
NSMutableDictionary *userInfo =
[NSMutableDictionary
dictionaryWithObject:[NSNumber numberWithInt:signal]
- forKey:UncaughtExceptionHandlerSignalKey];
-
+ forKey:RNUncaughtExceptionHandlerSignalKey];
+
NSArray *callStack = [ReactNativeExceptionHandler backtrace];
[userInfo
setObject:callStack
- forKey:UncaughtExceptionHandlerAddressesKey];
-
+ forKey:RNUncaughtExceptionHandlerAddressesKey];
+
[[[ReactNativeExceptionHandler alloc] init]
performSelectorOnMainThread:@selector(handleException:)
withObject:
[NSException
- exceptionWithName:UncaughtExceptionHandlerSignalExceptionName
+ exceptionWithName:RNUncaughtExceptionHandlerSignalExceptionName
reason:
[NSString stringWithFormat:
NSLocalizedString(@"Signal %d was raised.", nil),
@@ -201,7 +201,7 @@ void SignalHandler(int signal)
userInfo:
[NSDictionary
dictionaryWithObject:[NSNumber numberWithInt:signal]
- forKey:UncaughtExceptionHandlerSignalKey]]
+ forKey:RNUncaughtExceptionHandlerSignalKey]]
waitUntilDone:YES];
}
@@ -215,19 +215,19 @@ void SignalHandler(int signal)
void* callstack[128];
int frames = backtrace(callstack, 128);
char **strs = backtrace_symbols(callstack, frames);
-
+
int i;
NSMutableArray *backtrace = [NSMutableArray arrayWithCapacity:frames];
for (
- i = UncaughtExceptionHandlerSkipAddressCount;
- i < UncaughtExceptionHandlerSkipAddressCount +
- UncaughtExceptionHandlerReportAddressCount;
+ i = RNUncaughtExceptionHandlerSkipAddressCount;
+ i < RNUncaughtExceptionHandlerSkipAddressCount +
+ RNUncaughtExceptionHandlerReportAddressCount;
i++)
{
[backtrace addObject:[NSString stringWithUTF8String:strs[i]]];
}
free(strs);
-
+
return backtrace;
}
from react-native-exception-handler.
@peteroid Awesome ! Can you raise a PR for the same ?
from react-native-exception-handler.
@master-atul created PR according to the patch. #16
from react-native-exception-handler.
Thanks @peteroid The PR is merged . Will release a new version in a bit.
from react-native-exception-handler.
Related Issues (20)
- Android not sending fetch in setNativeExceptionHandler HOT 6
- warning and error is not fatal ?
- Not Working with crashlytics HOT 3
- Error not captured: ReferenceError: variable is not defined
- What's the technical reason native exception can't be reported to JS as events?
- Navigate to Contact us screen HOT 1
- change readme to show "deprecated" status
- Question: how to mock? HOT 1
- Is it possible to restart the application from the modal?
- Maximum call stack size exceeded (native stack depth)
- Get ride of default alert when app crash [Android]
- JS Code not beign called on Native Exception Android HOT 1
- Fetch operations not working inside nativehandler HOT 2
- Write log into device memory
- Add example for native Code in Android example
- [QUESTION] Is this library deprecated? HOT 5
- Unable to obtain incorrect message HOT 1
- "Occured" should be "Occurred"
- DefaultErrorScreen in android is not showing
- Incompatible with Gradle 8 and above while generating release builds and app bundles HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-exception-handler.