-
-
Notifications
You must be signed in to change notification settings - Fork 338
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
[Android] ReferenceError not being captured by Sentry #4321
Comments
Hi and thank you for opening this issue!, Could you share the logs from Sentry when debug is set to true? Lastly, could you share a snippet on how you are calling this function? |
@lucas-zimerman Thanks for the prompt response!
Here is the example code snippet const functionA = (
var1: number,
var2: number,
var3: string,
) => {
callFunction1({
param1: {},
param2: () => callFunction2(),
});
};
useEffect(() => {
if (
!varA &&
((varQ === '' && !bool) || (varQ === '1' && bool))
) {
const num = 1
if (num) {
functionA(
var1,
var2,
var3,
);
}
}
}, []); In the above code snippet, Checking v5.34.0, will post the results shortly. |
Package update from v5.33.1 -> v5.34.0 did not log the Sentry event as well. |
Thank you for the details and testing it with the latest v5. |
@lucas-zimerman Have you reproduced this error? |
Hi @krystofwoldrich, I am still investigating this case to see if it's affecting V6 or only V5 |
Thank you, please post a comment, when you know more/were able to reproduce. |
I'm able to reproduce this on v6.4.0, |
@krystofwoldrich Using the following snippet: PerformanceScreen.tsx
...
const PerformanceScreen = (props: Props) => {
+ const handleSyncError = () => {
+ undefinedFunction();
+ };
+ React.useEffect(() => {
+ handleSyncError();
+ }, []);
...
So far this is what I found:
Using an async function surely works, but on the other hand React Native doesn't crash in this case, so it could be related to how React Native is dealing with crashes. Those issues could be related to what @shanmukhdontuTWM is facing, but just as a sanity check, @shanmukhdontuTWM would you be able to make a minimal repro of your issue just to make sure if the issues that I found are related to the issues that you are facing of if you are actually facing another issue? |
@lucas-zimerman Currently we are setting As mentioned above, when we set it to async - react native does not crash and sends the event to sentry. |
Thank you @shanmukhdontuTWM for the details. |
Can you please investigate this further and share more information here in the thread? |
@shanmukhdontuTWM when you face the issue with the sync function, does your JS thread gets blocked? You can test this by running the following code before making the error let test2 = 0
const parsedStack = parseErrorStack(rawStack);
function printEverySecond(): void {
setInterval(() => {
console.log(test2);
test2++;
}, 1);
}
printEverySecond(); If you don't see any number higher than 0 it means your JS thread got blocked. Internal: There seems to be an edge case where undefined synchronous variables may not log if added on
The code above seems to be triggering it, but I don't believe it is doing it because the code is broken, it is more likely the JS engine is going to die so we run on a limited timestamp for logging the error. It seems like on the sample app if we disable const withTimeout = <T>(promise: Promise<T>, timeoutMs: number): Promise<T | null> => {
return Promise.race([
promise,
new Promise<null>((resolve) => setTimeout(() => {
resolve(null)
}, timeoutMs)),
]);
};
...
const prettyStack = await withTimeout(symbolicateStackTrace(parsedStack), 2000); The SDK will hang and no event will be sent. When the JS Hang happens, there seems to be a native error that is also not logged: Unhandled SoftException
com.facebook.react.bridge.ReactNoCrashSoftException: raiseSoftException(getOrCreateDestroyTask()): handleHostException(message = "addViewAt: failed to insert view [212] into parent [214] at index 0")
at com.facebook.react.runtime.ReactHostImpl.raiseSoftException(ReactHostImpl.java:942)
at com.facebook.react.runtime.ReactHostImpl.getOrCreateDestroyTask(ReactHostImpl.java:1575)
at com.facebook.react.runtime.ReactHostImpl.lambda$destroy$7(ReactHostImpl.java:541)
at com.facebook.react.runtime.ReactHostImpl.$r8$lambda$uso21_D6dCZdcf-JomVD56kdG4c(Unknown Source:0)
at com.facebook.react.runtime.ReactHostImpl$$ExternalSyntheticLambda37.call(D8$$SyntheticClass:0)
at com.facebook.react.runtime.internal.bolts.Task$2.run(Task.java:240)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.IllegalStateException: addViewAt: failed to insert view [212] into parent [214] at index 0
at com.facebook.react.fabric.mounting.SurfaceMountingManager.addViewAt(SurfaceMountingManager.java:416)
at com.facebook.react.fabric.mounting.mountitems.IntBufferBatchMountItem.execute(IntBufferBatchMountItem.java:119)
at com.facebook.react.fabric.mounting.MountItemDispatcher.executeOrEnqueue(MountItemDispatcher.java:387)
at com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchMountItems(MountItemDispatcher.java:293)
at com.facebook.react.fabric.mounting.MountItemDispatcher.tryDispatchMountItems(MountItemDispatcher.java:126)
at com.facebook.react.fabric.FabricUIManager$DispatchUIFrameCallback.doFrameGuarded(FabricUIManager.java:1388)
at com.facebook.react.fabric.GuardedFrameCallback.doFrame(GuardedFrameCallback.kt:22)
at com.facebook.react.modules.core.ReactChoreographer.frameCallback$lambda$1(ReactChoreographer.kt:60)
at com.facebook.react.modules.core.ReactChoreographer.$r8$lambda$nSkFhrr5T7rop_XKwzlLov4NLLw(Unknown Source:0)
at com.facebook.react.modules.core.ReactChoreographer$$ExternalSyntheticLambda0.doFrame(D8$$SyntheticClass:0)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1337)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1348)
at android.view.Choreographer.doCallbacks(Choreographer.java:952)
at android.view.Choreographer.doFrame(Choreographer.java:878)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1322)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:5275)
at android.view.ViewGroup.addView(ViewGroup.java:5104)
at com.facebook.react.views.view.ReactViewGroup.addView(ReactViewGroup.java:608)
at android.view.ViewGroup.addView(ViewGroup.java:5044)
at com.facebook.react.views.view.ReactClippingViewManager.addView(ReactClippingViewManager.java:41)
at com.facebook.react.views.view.ReactClippingViewManager.addView(ReactClippingViewManager.java:21)
at com.facebook.react.fabric.mounting.SurfaceMountingManager.addViewAt(SurfaceMountingManager.java:413)
at com.facebook.react.fabric.mounting.mountitems.IntBufferBatchMountItem.execute(IntBufferBatchMountItem.java:119)
at com.facebook.react.fabric.mounting.MountItemDispatcher.executeOrEnqueue(MountItemDispatcher.java:387)
at com.facebook.react.fabric.mounting.MountItemDispatcher.dispatchMountItems(MountItemDispatcher.java:293)
at com.facebook.react.fabric.mounting.MountItemDispatcher.tryDispatchMountItems(MountItemDispatcher.java:126)
at com.facebook.react.fabric.FabricUIManager$DispatchUIFrameCallback.doFrameGuarded(FabricUIManager.java:1388)
at com.facebook.react.fabric.GuardedFrameCallback.doFrame(GuardedFrameCallback.kt:22)
at com.facebook.react.modules.core.ReactChoreographer.frameCallback$lambda$1(ReactChoreographer.kt:60)
at com.facebook.react.modules.core.ReactChoreographer.$r8$lambda$nSkFhrr5T7rop_XKwzlLov4NLLw(Unknown Source:0)
at com.facebook.react.modules.core.ReactChoreographer$$ExternalSyntheticLambda0.doFrame(D8$$SyntheticClass:0)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1337)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1348)
at android.view.Choreographer.doCallbacks(Choreographer.java:952)
at android.view.Choreographer.doFrame(Choreographer.java:878)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1322)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) |
What React Native libraries do you use?
React Navigation, Hermes
Are you using sentry.io or on-premise?
sentry.io (SaS)
@sentry/react-native SDK Version
5.33.1
How does your development environment look like?
Sentry.init()
Steps to Reproduce
The app is getting initialized with sentry without any issue, and also the sentry crash test is working.
In a component inside the App, it does not have a function imported and is called, which is throwing a ReferenceError locally but the same issue is not populated in sentry. When i converted the function to
async
, it did the trick.The app is within the sentry error boundary and we were expecting the crash to show up, even for synchronous functions but thats not the case.
Can someone help look into this?
Expected Result
The event should be logged on sentry dashboard, sentry should capture one.
Actual Result
Sentry not able to capture ReferenceError crashes inside a React native component
The text was updated successfully, but these errors were encountered: