getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.57k stars 337 forks source link

Unhandled JS Errors are not registered in iOS #911

Closed gramotei closed 4 years ago

gramotei commented 4 years ago

Platform:

SDK:

SDK version: 1.4.2

react-native version: 0.62.1

Are you using Expo?

Are you using sentry.io or on-premise?

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn:
    'https://14....@o74....ingest.sentry.io/5.....',
  debug: true,
});

I have following issue:

Can't get Sentry to report unhandled JS crashes

Steps to reproduce:

Actual result:

After getting to screen with Error the app crashes immediately without report to be sent

Expected result:

App is sending the report before termination

dehlen commented 4 years ago

Also using 1.4.2 and am seeing this behavior. Downgrade to 1.4.1 did not resolve the issue, however 1.3.7 did work for me as expected. Any ideas for a quick fix? We would love to upgrade to the latest version as soon as possible. If you need any further information let me know :)

jennmueng commented 4 years ago

Hmm, that's very interesting. I'm not sure why 1.4.x wouldn't work for you while 1.3.7 does. When you were upgrading, did you ensure the installation is all correct (pod install and everything, along with maybe trying a full node_modules delete and reinstall?).

Does it work as intended when Sentry.captureException() or Sentry.captureMessage() is called directly?

dehlen commented 4 years ago

Pretty sure installation is all fine. I am testing with our CI build which always is a clean build. Also it seems to work just fine for the Android app. I'll check whether it works correctly when calling the two methods from above correctly.

dehlen commented 4 years ago

Can confirm that calling Sentry.captureException() does indeed report the correct error event and that I can see the stack trace.

gramotei commented 4 years ago

Hmm, that's very interesting. I'm not sure why 1.4.x wouldn't work for you while 1.3.7 does. When you were upgrading, did you ensure the installation is all correct (pod install and everything, along with maybe trying a full node_modules delete and reinstall?).

Does it work as intended when Sentry.captureException() or Sentry.captureMessage() is called directly?

Sentry.captureMessage() works fine. I think the problem is located somewhere here:


if (client && !__DEV__) {
    client.flush(client.getOptions().shutdownTimeout || 2000).then(() => {
        defaultHandler(error, isFatal);
    });
}
dehlen commented 4 years ago

Since it works for us with the Android App (which obviously uses the same sentry-react-native SDK) I think this might be related to the breaking API changes introduced in sentry-cocoa 5.x?

EDIT: Not quite sure how the react-native crashes are handled by this SDK but if it is a C++ exception which is thrown this might be related: https://github.com/getsentry/sentry-cocoa/issues/551 and could explain the issue I am seeing.

jennmueng commented 4 years ago

Hmm can you guys turn on debug mode in Sentry.init and paste the logs? Will try to get you guys up and running asap.

dehlen commented 4 years ago

Sure this is the output. Seems like the stack trace is captured correctly (see onPress etc.). We have a JS Test Crash in the apps debug setting when a button is clicked, so the stack trace is the correct one.

"Initialize disabled Sentry Client for environment: nonProduction"
"Sentry Crash Reporting Status changed to: Enabled"
"Sentry client initialized!"
"Sentry Crash Reporting Status changed to: Enabled"

2020-06-05 11:10:39.109027+0200 meindm[397:15019] Sentry - Debug:: SDK initialized! Version: 5.1.1
2020-06-05 11:10:39.109223+0200 meindm[397:15019] Sentry - Debug:: Integration installed: SentryCrashIntegration
2020-06-05 11:10:39.109275+0200 meindm[397:15019] Sentry - Debug:: Add breadcrumb: <SentryBreadcrumb: 0x281fb2100>
2020-06-05 11:10:39.109568+0200 meindm[397:15019] Sentry - Debug:: Integration installed: SentryAutoBreadcrumbTrackingIntegration
2020-06-05 11:10:39.109606+0200 meindm[397:15019] Sentry - Debug:: Integration installed: SentryAutoSessionTrackingIntegration

2020-06-05 11:10:53.503 [error][tid:com.facebook.react.JavaScript] Error: This is a test javascript crash!
2020-06-05 11:10:53.508 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Error: This is a test javascript crash!
2020-06-05 11:10:53.510766+0200 meindm[397:15314] ERROR: uncaught exception: Unhandled JS Exception: Error: This is a test javascript crash!, stack:
onPress@1169:6650
touchableHandlePress@344:2602
touchableHandlePress@<null>:<null>
_performSideEffectsForTransition@217:9621
_performSideEffectsForTransition@<null>:<null>
_receiveSignal@217:8357
_receiveSignal@<null>:<null>
touchableHandleResponderRelease@217:5645
touchableHandleResponderRelease@<null>:<null>
y@97:1197
S@97:1340
C@97:1394
N@97:1692
A@97:2482
forEach@<null>:<null>
z@97:2282
<unknown>@97:13914
_e@97:88042
Ne@97:13582
Ue@97:13755
receiveTouches@97:14547
value@27:3685
<unknown>@27:841
value@27:2939
value@27:813
value@<null>:<null>
2020-06-05 11:10:53.514781+0200 meindm[397:15314] ERROR: Stack: (
    0   CoreFoundation                      0x00000001b6bd17a8 50CF3336-313F-3A7D-9048-CB1ED8EC3368 + 1222568
    1   libobjc.A.dylib                     0x00000001b68f3bcc objc_exception_throw + 56
    2   meindm                              0x0000000101533530 RCTGetFatalHandler + 0
    3   meindm                              0x0000000100dcfe10 -[RCTExceptionsManager reportFatalException:stack:exceptionId:] + 560
    4   CoreFoundation                      0x00000001b6bd7970 50CF3336-313F-3A7D-9048-CB1ED8EC3368 + 1247600
    5   CoreFoundation                      0x00000001b6aa8bb0 50CF3336-313F-3A7D-9048-CB1ED8EC3368 + 7088
    6   CoreFoundation                      0x00000001b6aa9788 50CF3336-313F-3A7D-9048-CB1ED8EC3368 + 10120
    7   meindm                              0x00000001015800f0 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 536
    8   meindm                              0x000000010158299c _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 284
    9   meindm                              0x0000000101582618 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 120
    10  libdispatch.dylib                   0x00000001049ee338 _dispatch_call_block_and_release + 24
    11  libdispatch.dylib                   0x00000001049ef730 _dispatch_client_callout + 16
    12  libdispatch.dylib                   0x00000001049f6740 _dispatch_lane_serial_drain + 744
    13  libdispatch.dylib                   0x00000001049f72e0 _dispatch_lane_invoke + 444
    14  libdispatch.dylib                   0x0000000104a026c4 _dispatch_workloop_worker_thread + 1304
    15  libsystem_pthread.dylib             0x00000001b68e8b74 _pthread_wqthread + 272
    16  libsystem_pthread.dylib             0x00000001b68eb740 start_wqthread + 8
)

2020-06-05 11:10:53.515313+0200 meindm[397:15314] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Error: This is a test javascript crash!', reason: 'Unhandled JS Exception: Error: This is a test javascript crash!, stack:
onPress@1169:6650
touchableHandlePress@344:2602
touchableHandlePress@<null>:<null>
_performSideEffectsForTransition@217:9621
_performSideEffectsForTransition@<null>:<null>
_receiveSignal@217:8357
_receiveSignal@<null>:<null>
touchableHandleResponderRelease@217:5645
touchableHandleResponderRelease@<null>:<null>
y@97:1197
S@97:1340
C@97:1394
N@97:1692
A@97:2482
forEach@<null>:<null>
z@97:2282
<unknown>@97:13914
_e@97:88042
Ne@97:13582
Ue@97:13755
receiveTouches@97:14547
value@27:3685
<unknown>@27:841
value@27:2939
value@27:813
value@<null>:<null>
'
*** First throw call stack:
(0x1b6bd1794 0x1b68f3bcc 0x101533530 0x100dcfe10 0x1b6bd7970 0x1b6aa8bb0 0x1b6aa9788 0x1015800f0 0x10158299c 0x101582618 0x1049ee338 0x1049ef730 0x1049f6740 0x1049f72e0 0x104a026c4 0x1b68e8b74 0x1b68eb740)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

However all I see in the sentry console is a CPPException with no stack trace. I created a public link for the particular issue: https://sentry.io/share/issue/a095242f8f9b43c8a5103f8b0e470ae2/.

Please note that I also get a processing error on the Sentry website:

There was 1 error encountered while processing this event
threads.values.14.stacktrace.frames: Discarded invalid value
HazAT commented 4 years ago

@dehlen It seems our React Native SDK is not able to pick up the crash in JS to send it to native. How are you initializing the SDK in JS? When do you throw the error? Do you have any other dependencies that tinker with the react native error handler?

dehlen commented 4 years ago

Initialization in JS:

const shouldSendEvent: (event: Sentry.Event, hint?: SentryTypes.EventHint) => Promise<Sentry.Event | null> = async (event: Sentry.Event) => {
  if (latestConfiguration.hasOwnProperty('release')) {
    event.release = latestConfiguration.release;
  }

  if (latestConfiguration.hasOwnProperty('userId')) {
    event.user = { id: latestConfiguration.userId }
  }

  return latestConfiguration.crashReportingEnabled ? event : null;
};

Sentry.init({
    beforeSend: shouldSendEvent,
    beforeBreadcrumb(breadcrumb, hint) {
      return null;
    },
    dsn: latestConfiguration.dsn,
    enableNative: true,
    enableNativeCrashHandling: true,
    enabled: true,
    environment: latestConfiguration.environment,
    debug: true
  });

Throwing the error:

<Button
  label="Crash App"
  onPress={() => {
      throw new Error('This is a test javascript crash!');
  }}
/>

I do not think that we have any other dependency tinkering with the react-native error handler. On Android the error is reported correctly. But I will browse through all the dependencies to see if I find something which seems suspicious.

dehlen commented 4 years ago

Thank you all for the quick responses and the support 👍

gramotei commented 4 years ago

Here is mine

import * as Sentry from '@sentry/react-native';

Sentry.init({
  dsn,  debug: true,
});

to throw I use component:

  const store = useStore();

  throw Error("Sentry, Please Catch This Unhandled Exception");
2020-06-05 12:26:36.419296+0300 [14564:3495043] Sentry - Debug:: SDK initialized! Version: 5.1.1
2020-06-05 12:26:36.428621+0300 [14564:3495043] Sentry - Debug:: Sent 0 crash report(s)
2020-06-05 12:26:36.428775+0300 [14564:3495043] Sentry - Debug:: Integration installed: SentryCrashIntegration
2020-06-05 12:26:36.428829+0300 [14564:3495043] Sentry - Debug:: Add breadcrumb: <SentryBreadcrumb: 0x280be3e40>
2020-06-05 12:26:36.429398+0300 [14564:3495043] Sentry - Debug:: Integration installed: SentryAutoBreadcrumbTrackingIntegration
2020-06-05 12:26:36.429439+0300 [14564:3495043] Sentry - Debug:: Integration installed: SentryAutoSessionTrackingIntegration
2020-06-05 12:26:36.450 [error][tid:com.facebook.react.JavaScript] Error: Sentry, Please Catch This Unhandled Exception

This error is located at:
    in Unknown
    in Unknown
    in Unknown
    in Unknown
    in Unknown
    in RCTView
    in RCTView
    in RCTView
    in RCTView
    in k
    in ForwardRef
    in PanGestureHandler
    in RCTView
    in k
    in ForwardRef
    in RCTView
    in D
    in Unknown
    in RCTView
    in C
    in RCTView
    in H
    in S
    in h
    in Unknown
    in RCTView
    in b
    in Unknown
    in RCTView
    in Unknown
    in Unknown
    in ForwardRef
    in Unknown
    in ForwardRef
    in Unknown
    in RNCSafeAreaView
    in Unknown
    in A
    in RCTView
    in RCTView
    in E
2020-06-05 12:26:36.455157+0300 [14564:3495043] Bridge call to: deviceContexts
2020-06-05 12:26:36.894 [error][tid:com.facebook.react.JavaScript] Error: Sentry, Please Catch This Unhandled Exception

This error is located at:
    in Unknown
    in Unknown
    in Unknown
    in Unknown
    in Unknown
    in RCTView
    in RCTView
    in RCTView
    in RCTView
    in k
    in ForwardRef
    in PanGestureHandler
    in RCTView
    in k
    in ForwardRef
    in RCTView
    in D
    in Unknown
    in RCTView
    in C
    in RCTView
    in H
    in S
    in h
    in Unknown
    in RCTView
    in b
    in Unknown
    in RCTView
    in Unknown
    in Unknown
    in ForwardRef
    in Unknown
    in ForwardRef
    in Unknown
    in RNCSafeAreaView
    in Unknown
    in A
    in RCTView
    in RCTView
    in E
2020-06-05 12:26:36.899 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Error: Sentry, Please Catch This Unhandled Exception

This error is located at:
    in Unknown
    in Unknown
    in Unknown
    in Unknown
    in Unknown
    in RCTView
    in RCTView
    in RCTView
    in RCTView
    in k
    in ForwardRef
    in PanGestureHandler
    in RCTView
    in k
    in ForwardRef
    in RCTView
    in D
    in Unknown
    in RCTView
    in C
    in RCTView
    in H
    in S
    in h
    in Unknown
    in RCTView
    in b
    in Unknown
    in RCTView
    in Unknown
    in Unknown
    in ForwardRef
    in Unknown
    in ForwardRef
    in Unknown
    in RNCSafeAreaView
    in Unknown
    in A
    in RCTView
    in RCTView
    in E
2020-06-05 12:26:37.018036+0300 [14564:3495185] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Error: Sentry, Please Catch This Unhandled Exception

This error is located at:
    in Unknown
    in Unknown
    in Unknown
    in Unknown
    in Unknown
    in RCTView
    in RCTView
    in RCTView
    in RCTView
    in k
    in ForwardRef
    in PanGestureHandler
    in RCTView
    in k
    in ForwardRef
    in RCTView
    in D
    in Unknown
    in RCTView
    in C
    in RCTView
    in H
    in S
    in h
    in Unknown
    in RCTView
    in b
    in Unknown
    in RCTView
    in Unknown
    in Unknown
    in ForwardRef
    in Unknown
    in ForwardRef
    in Unknown
    in RNCSafeAreaView
    in Unknown
    in A
    in RCTView
    in RCTView
    in E', reason: 'Unhandled JS Exception: Error: Sentry, Please Catch This Unhandled Exception

This error is located at:
    in Unknown
    in Unknown
    in Unknown

    in Unknown
    in Unkn..., stack:
<unknown>@954:371
_r@97:41256
ji@97:82068
ja@97:72034
Oa@97:71959
Ia@97:69253
Ia@(null):(null)
<unknown>@97:25480
<unknown>@184:3503
dn@97:25427
fn@97:25362
Pe@97:90879
Re@97:13478
Ie@97:13664
receiveEvent@97:14065
value@27:3544
<unknown>@27:840
value@27:2798
value@27:812
value@(null):(null)
'
*** First throw call stack:
(0x1a4b44164 0x1a4858c1c 0x100cc7364 0x100d409e0 0x100d413ec 0x1a4b4ad14 0x1a4a13de8 0x1a4a14a10 0x100cf61b0 0x100cf829c 0x100cf8000 0x101659d10 0x10165b18c 0x101662968 0x101663580 0x10166f0f0 0x1a484b714 0x1a48519c8)
libc++abi.dylib: terminating with uncaught exception of type NSException
HazAT commented 4 years ago

Thank you, both configs looks OK

One thing I noticed what seems very odd, your log should look something like this in the beginning:

...
2020-06-05 11:47:29.801834+0200 sample[48902:14203617] Sentry - Debug:: SDK initialized! Version: 5.1.2
2020-06-05 11:47:29.803 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: ReactNativeErrorHandlers
2020-06-05 11:47:29.803 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: Release
2020-06-05 11:47:29.803 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: InboundFilters
2020-06-05 11:47:29.803 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: FunctionToString
2020-06-05 11:47:29.804 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: Breadcrumbs
2020-06-05 11:47:29.804 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: LinkedErrors
2020-06-05 11:47:29.804 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: UserAgent
2020-06-05 11:47:29.804 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: DebugSymbolicator
2020-06-05 11:47:29.804 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: RewriteFrames
2020-06-05 11:47:29.804 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: DeviceContext
2020-06-05 11:47:29.806643+0200 sample[48902:14203617] Sentry - Debug:: Sent 0 crash report(s)
2020-06-05 11:47:29.806848+0200 sample[48902:14203617] Sentry - Debug:: Integration installed: SentryCrashIntegration
...

Notice the missing Sentry Logger [Log]: messages? These come from the JS SDK. So for whatever reason, it seems like the JS SDK isn't fully initialized. Are you setting a DSN?

gramotei commented 4 years ago

@HazAT I think that is because it is a Release build. To make sure __DEV__ is false. When I run in Dev mode I can see it.

[Fri Jun 05 2020 12:53:27.245]  LOG      Sentry Logger [Log]: Integration installed: ReactNativeErrorHandlers
[Fri Jun 05 2020 12:53:27.245]  LOG      Sentry Logger [Log]: Integration installed: Release
[Fri Jun 05 2020 12:53:27.245]  LOG      Sentry Logger [Log]: Integration installed: InboundFilters
[Fri Jun 05 2020 12:53:27.246]  LOG      Sentry Logger [Log]: Integration installed: FunctionToString
[Fri Jun 05 2020 12:53:27.246]  LOG      Sentry Logger [Log]: Integration installed: Breadcrumbs
[Fri Jun 05 2020 12:53:27.246]  LOG      Sentry Logger [Log]: Integration installed: LinkedErrors
[Fri Jun 05 2020 12:53:27.246]  LOG      Sentry Logger [Log]: Integration installed: UserAgent
[Fri Jun 05 2020 12:53:27.247]  LOG      Sentry Logger [Log]: Integration installed: DebugSymbolicator
[Fri Jun 05 2020 12:53:27.247]  LOG      Sentry Logger [Log]: Integration installed: RewriteFrames
[Fri Jun 05 2020 12:53:27.248]  LOG      Sentry Logger [Log]: Integration installed: DeviceContext
HazAT commented 4 years ago

Cool ok, I am trying to reproduce this locally in the sample project we have. To explain the problem (that I expect): The exceptions [error][tid:com.facebook.react.JavaScript] Error: like this with the attached JS stack trace should never bubble up to native like this. Usually, our SDK catches it in JS, prepares it there, and forwards the finished event to native (which in both of your cases is not happening). Instead, it seems we skip the JS part and the exception gets forwarded to native immediately where our iOS SDK picks up an unhandled exception.

dehlen commented 4 years ago

Yes I can second this. I used a release build. When running a Debug build I also see the Sentry Logger logs. DSN is set.

dehlen commented 4 years ago

I see this makes sense. Thanks for looking into it.

gramotei commented 4 years ago

Just run on device with a Debug build. I can see it tracked on sentry.io after I see RedBox but not in Release one :(

flipper: FlipperClient::addPlugin Inspector
flipper: FlipperClient::addPlugin Preferences
flipper: FlipperClient::addPlugin React
flipper: FlipperClient::addPlugin Network
2020-06-05 13:06:24.013 [info][tid:main][RCTRootView.m:294] Running application r ({
    initialProps =     {
    };
    rootTag = 1;
})
2020-06-05 13:06:24.081369+0300 App[14669:3512478] [] nw_socket_handle_socket_event [C3.1:1] Socket SO_ERROR [61: Connection refused]
2020-06-05 13:06:24.082926+0300 App[14669:3512464] [] nw_socket_handle_socket_event [C3.2:1] Socket SO_ERROR [61: Connection refused]
2020-06-05 13:06:24.083483+0300 App[14669:3512478] [] nw_connection_get_connected_socket [C3] Client called nw_connection_get_connected_socket on unconnected nw_connection
2020-06-05 13:06:24.668226+0300 App[14669:3512478] TCP Conn 0x281498fc0 Failed : error 0:61 [61]
2020-06-05 13:06:25.723 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native/Libraries/Network/fetch.js -> node_modules/whatwg-fetch/dist/fetch.umd.js -> node_modules/react-native/Libraries/Network/fetch.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2020-06-05 13:06:25.724406+0300 App[14669:3512478] [] nw_socket_handle_socket_event [C5:1] Socket SO_ERROR [61: Connection refused]
2020-06-05 13:06:25.724593+0300 App[14669:3512466] [] nw_connection_get_connected_socket [C5] Client called nw_connection_get_connected_socket on unconnected nw_connection
2020-06-05 13:06:25.724635+0300 App[14669:3512466] TCP Conn 0x281499080 Failed : error 0:61 [61]
2020-06-05 13:06:25.727 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: ReactNativeErrorHandlers
2020-06-05 13:06:25.727 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: Release
2020-06-05 13:06:25.727 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: InboundFilters
2020-06-05 13:06:25.727 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: FunctionToString
2020-06-05 13:06:25.728 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: Breadcrumbs
2020-06-05 13:06:25.728 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: LinkedErrors
2020-06-05 13:06:25.728 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: UserAgent
2020-06-05 13:06:25.728 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: DebugSymbolicator
2020-06-05 13:06:25.728 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: RewriteFrames
2020-06-05 13:06:25.728 [info][tid:com.facebook.react.JavaScript] Sentry Logger [Log]: Integration installed: DeviceContext
2020-06-05 13:06:25.729750+0300 App[14669:3512242] Sentry - Debug:: SDK initialized! Version: 5.1.1
2020-06-05 13:06:25.734 [info][tid:com.facebook.react.JavaScript] Running "r" with {"rootTag":1,"initialProps":{}}
2020-06-05 13:06:25.735274+0300 App[14669:3512242] Sentry - Debug:: Sent 0 crash report(s)
2020-06-05 13:06:25.735412+0300 App[14669:3512242] Sentry - Debug:: Integration installed: SentryCrashIntegration
2020-06-05 13:06:25.735467+0300 App[14669:3512242] Sentry - Debug:: Add breadcrumb: <SentryBreadcrumb: 0x28341b580>
2020-06-05 13:06:25.736156+0300 App[14669:3512242] Sentry - Debug:: Integration installed: SentryAutoBreadcrumbTrackingIntegration
2020-06-05 13:06:25.736201+0300 App[14669:3512242] Sentry - Debug:: Integration installed: SentryAutoSessionTrackingIntegration
2020-06-05 13:06:25.779 [error][tid:com.facebook.react.JavaScript] Error: Sentry, Please Catch This Unhandled Exception

This error is located at:
    in RestaurantListScreen (at SceneView.tsx:98)
    in StaticContainer
    in StaticContainer (at SceneView.tsx:89)
    in EnsureSingleNavigator (at SceneView.tsx:88)
    in SceneView (at useDescriptors.tsx:125)
    in RCTView (at CardContainer.tsx:190)
    in RCTView (at CardContainer.tsx:189)
    in RCTView (at Card.tsx:525)
    in RCTView (at createAnimatedComponent.js:144)
    in AnimatedComponent (at createAnimatedComponent.js:194)
    in ForwardRef(AnimatedComponentWrapper) (at Card.tsx:508)
    in PanGestureHandler (at Card.tsx:501)
    in RCTView (at createAnimatedComponent.js:144)
    in AnimatedComponent (at createAnimatedComponent.js:194)
    in ForwardRef(AnimatedComponentWrapper) (at Card.tsx:497)
    in RCTView (at Card.tsx:491)
    in Card (at CardContainer.tsx:156)
    in CardContainer (at CardStack.tsx:531)
    in RCTView (at CardStack.tsx:106)
    in MaybeScreen (at CardStack.tsx:524)
    in RCTView (at CardStack.tsx:89)
    in MaybeScreenContainer (at CardStack.tsx:422)
    in CardStack (at StackView.tsx:420)
    in KeyboardManager (at StackView.tsx:418)
    in SafeAreaProviderCompat (at StackView.tsx:415)
    in RCTView (at StackView.tsx:414)
    in StackView (at createStackNavigator.tsx:67)
    in StackNavigator (at App.js:61)
    in RCTView
    in Unknown (at App.js:60)
    in EnsureSingleNavigator (at BaseNavigationContainer.tsx:268)
    in ForwardRef(BaseNavigationContainer) (at NavigationContainer.tsx:39)
    in ThemeProvider (at NavigationContainer.tsx:38)
    in ForwardRef(NavigationContainer) (at App.js:59)
    in StoreProvider (at App.js:58)
    in RNCSafeAreaView (at src/index.tsx:28)
    in SafeAreaProvider (at App.js:57)
    in App (at renderApplication.js:45)
    in RCTView (at AppContainer.js:109)
    in RCTView (at AppContainer.js:135)
    in AppContainer (at renderApplication.js:39)
2020-06-05 13:06:25.792 [warn][tid:com.facebook.react.JavaScript] 'Warning: %s: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.', 'App', '\n    in App (at renderApplication.js:45)'
2020-06-05 13:06:26.102613+0300 App[14669:3512242] Bridge call to: deviceContexts
2020-06-05 13:06:26.102754+0300 App[14669:3512242] Contexts: {"os":{"build":"17E262","rooted":false,"kernel_version":"Darwin Kernel Version 19.4.0: Mon Feb 24 22:04:54 PST 2020; root:xnu-6153.102.3~1\/RELEASE_ARM64_T8020","name":"iOS","version":"13.4.1"},"device":{"free_memory":81657856,"model_id":"D321AP","arch":"arm64e","memory_size":3953475584,"family":"iOS","model":"iPhone11,2","storage_size":255937040384,"boot_time":"2020-05-28T11:49:23Z","timezone":"EEST","usable_memory":2536554496},"app":{"app_id":"94BF6F67-FEEB-3D17-8A84-0D2A5F48E66D","app_version":"1.0","app_identifier":"","app_start_time":"2020-06-05T10:06:25Z","device_app_hash":"d04df006b0aea812578f32b157abb281549298d1","app_build":"14","build_type":"debug","app_name":"App"}}
2020-06-05 13:07:54.019175+0300 App[14669:3512242] [ApplicationLifecycle] UIWindows were created prior to initial application activation. This may result in incorrect visual appearance.
HazAT commented 4 years ago

OK, I think I found the issue. It was not exactly what I thought, working on a fix.

HazAT commented 4 years ago

@gramotei @dehlen Can you please upgrade to 1.4.4 and make sure you also install latest sentry-cocoa with pod install

After that try it again, make sure when in release mode and the app crashes we send the report after the restart.

gramotei commented 4 years ago

@HazAT doesn't help :( Tried several times

  - RNSentry (1.4.4):
    - React
    - Sentry (~> 5.1.4)
  - RNVectorIcons (6.6.0):
    - React
  - Sentry (5.1.4):
    - Sentry/Core (= 5.1.4)
  - Sentry/Core (5.1.4)

2020-06-05 18:03:37.981785+0300 App[15357:3646703] Sentry - Debug:: SDK initialized! Version: 5.1.4
2020-06-05 18:03:37.996173+0300 App[15357:3646703] Sentry - Debug:: Integration installed: SentryCrashIntegration
2020-06-05 18:03:37.996246+0300 App[15357:3646703] Sentry - Debug:: Add breadcrumb: <SentryBreadcrumb: 0x281cb9540>
2020-06-05 18:03:37.997710+0300 App[15357:3646703] Sentry - Debug:: Integration installed: SentryAutoBreadcrumbTrackingIntegration
2020-06-05 18:03:37.997744+0300 App[15357:3646703] Sentry - Debug:: Integration installed: SentryAutoSessionTrackingIntegration
2020-06-05 18:03:37.998013+0300 App[15357:3646703] Sentry - Debug:: Add breadcrumb: <SentryBreadcrumb: 0x281cb9700>
2020-06-05 18:03:38.003937+0300 App[15357:3646897] Unhandled JS Exception
2020-06-05 18:03:38.136 [info][tid:main][RNGestureHandlerManager.m:136] [GESTURE HANDLER] Initialize gesture handler for root view <RCTRootContentView: 0x14fd0c500; reactTag: 1; frame = (0 0; 375 812); gestureRecognizers = <NSArray: 0x2807ad3e0>; layer = <CALayer: 0x2809fc8c0>>
2020-06-05 18:03:42.874503+0300 App[15357:3646703] Bridge call to: deviceContexts
2020-06-05 18:03:42.893 [error][tid:com.facebook.react.JavaScript] Error: Sentry, Please Catch This Unhandled Exception Fri, 05 Jun 2020 15:03:42 GMT
2020-06-05 18:03:42.895 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Error: Sentry, Please Catch This Unhandled Exception Fri, 05 Jun 2020 15:03:42 GMT
2020-06-05 18:03:42.896856+0300 App[15357:3646898] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Error: Sentry, Please Catch This Unhandled Exception Fri, 05 Jun 2020 15:03:42 GMT', reason: 'Unhandled JS Exception: Error: Sentry, Please Catch This Unhandled Exception Fri, 05 Jun 2020 15:03:42 GMT, stack:
V@955:1331
onPress@955:365
<unknown>@420:2461
<unknown>@411:2074
<unknown>@402:964
y@97:1125
k@97:1268
w@97:1322
R@97:1617
M@97:2401
U@97:2216
<unknown>@97:13818
Pe@97:90852
Re@97:13478
Ie@97:13664
receiveEvent@97:14065
value@27:3544
<unknown>@27:840
value@27:2798
value@27:812
value@(null):(null)
'
*** First throw call stack:
(0x1a4b44164 0x1a4858c1c 0x100f46124 0x100fbf7a0 0x100fc01ac 0x1a4b4ad14 0x1a4a13de8 0x1a4a14a10 0x100f74f70 0x100f7705c 0x100f76dc0 0x10177dd10 0x10177f18c 0x101786968 0x101787580 0x1017930f0 0x1a484b714 0x1a48519c8)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
dehlen commented 4 years ago

Thank you very much. For me its fixed in 1.4.4 👍

gramotei commented 4 years ago

Thank you very much. For me its fixed in 1.4.4 👍

Lucky you :)

dariakoko commented 4 years ago

Hello I have the same issue. Get sentry reports when Android crashes and don't get any when iOS crashes.

I have: react-native 0.61.0 @sentry/react-native: ^1.4.4

With sentry version 1.3.7 it was working fine

HazAT commented 4 years ago

@gramotei I am still trying to figure out what's going wrong on your end. I would need access to you app or you would need to add some debug statements into our SDK to figure out where exactly it's failing. In case you want to do some debug logs: Navigate to @sentry/react-native/dist/js/integrations/reactnativeerrorhandlers.js and place console.logs around line 77 client.flush(client.getOptions().shutdownTimeout || 2000).then(()

To make sure first of all we reach this code, and then do we call getCurrentHub().captureException on line 69 before we call the defaultHandler in line 78. (The time we call defaultHandler in Release, the app will crash)

gramotei commented 4 years ago

@HazAT I did that actually for 1.4.2 for debug build. that's why I supposed it is somewhere there. if you could advise me how to log it so I can see log messages when I run release version from Xcode I would appreciate it . EDIT: The app is in private alpha yet sorry

dariakoko commented 4 years ago

Version 1.4.2 works for both platforms So, I downgraded :/ If it's an option for you, @gramotei , try out

eeynard commented 4 years ago

Version 1.4.2 works for both platforms

It does not work for me (1.4.5 / 1.4.2). I can not downgrade to 1.3.7 because of this fix #820 RN : 0.62.2

I will try to find more information to help you guys figuring out this issue.

paulmars commented 4 years ago

1.4.2/1.4.5 didn't work for me. 1.3.7 appears to work for now.

meteorra commented 4 years ago

Hi @HazAT , are there any updates on this issue? Still experience it on versions 1.4.2/1.4.5

faridsaud commented 4 years ago

Same problem on 1.6.1 & RN 0.59.10. I had to go down to 1.3.7 and it worked.

benanderman commented 4 years ago

Same issue on 1.6.2 (and 1.4.5). I tried going down to 1.3.7, and THAT issue wasn't there, but on 1.3.7 I found that Android wasn't having context attached to native crashes. I'm trying to upgrade from react-native-sentry finally (having upgraded to React Native 0.61.5), and I really don't want to go back, but I'm not sure what to do if all of these versions have some significant issue.

benanderman commented 4 years ago

I just tested again on 1.6.2, and found that these errors ARE showing up, they're just delayed, and possibly only get reported when another event is sent. I thought that they weren't showing up at all, because I tested uncaught exceptions last, and didn't go back and check those issues. When one randomly showed up today, I clicked through old instances, and found there were actually a bunch. They show up with their original timestamp, so when I refreshed the page looking for new reports, I didn't notice that the count on the old instances had gone up.

jennmueng commented 4 years ago

@benanderman That is the intended design of the SDK, if the uncaught exception crashes and kills the app, the event will be cached and will be sent on the next open with the original timestamp.

benanderman commented 4 years ago

@jennmueng What you describe is what I expect, and it's what I see on Android and iOS Simulator on 1.6.2, and on iOS device on earlier versions. But on iOS device on 1.6.2, just starting the app again does not send the uncaught exception report. Yesterday I tried:

Only once have I seen it seemingly send without that second trigger, and it's very possible there was a trigger, just not something I was doing intentionally or noticed.

jennmueng commented 4 years ago

@benanderman So if I understand correctly, this occurs on device but not on the simulator correct? Does it occur for both development and production builds? Can I also see how the uncaught error is thrown/triggered? Thanks!

benanderman commented 4 years ago

@jennmueng That's correct. And good question; I only tested debug mode on simulator, and release mode on device. I don't currently have an easy way to test either debug mode on device (need to update OS), or release mode on simulator (just don't have the config setup to do this easily).

Triggering it looks like this:

const testUncaughtException = () => {
  throw new Error('Will not be caught');
};

/* ... */

<Button title="Uncaught exception" onPress={testUncaughtException} />
eeynard commented 4 years ago

I just upgraded to react-native-sentry@1.7.1 and react-native@0.63.2 and it seems to be working !!

jennmueng commented 4 years ago

Looks like this issue has been solved, closing it for now.

angelavanessaa commented 4 years ago

This issue is still persisting in the newest version react-native-sentry@1.8.2.