GithubHelp home page GithubHelp logo

Comments (6)

a7ul avatar a7ul commented on May 28, 2024 1

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.

hyb175 avatar hyb175 commented on May 28, 2024

Steps to re-create:

from react-native-exception-handler.

peteroid avatar peteroid commented on May 28, 2024

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.

a7ul avatar a7ul commented on May 28, 2024

@peteroid Awesome ! Can you raise a PR for the same ?

from react-native-exception-handler.

peteroid avatar peteroid commented on May 28, 2024

@master-atul created PR according to the patch. #16

from react-native-exception-handler.

a7ul avatar a7ul commented on May 28, 2024

Thanks @peteroid The PR is merged . Will release a new version in a bit.

from react-native-exception-handler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.