-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Node.js, React Native
-
2 - S (<= 1 week)
-
SDK FY21-Q3, SDK FY21-Q3.
-
2654
Goals
Realm should never crash a React Native app.
I suspect that we need to tell the JSCore engine that an unhandled exception happened during the execution of the callback.
I suspect this also happens if the error is thrown from other callbacks that we call from C++, therefore the following issues probably share the same root cause: https://github.com/realm/realm-js/issues/2029, https://github.com/realm/realm-js/issues/1439, https://github.com/realm/realm-js/issues/2233.
Expected Results
When an error is thrown from a callback added as a listener on a Results object, I expect an uncaught exception to be handled (resulting in a black screen with a red top-bar while in development mode).
Actual Results
When an error is thrown from a callback added as a listener on a Results object, the app crashes!
Steps to Reproduce & Code Sample
// App.js import React, { Component } from 'react'; import { View, Text } from 'react-native'; import Realm from 'realm' export default class App extends Component { componentDidMount() { const realm = new Realm({ schema: [{ name: "Singleton", properties: { value: "string" }, }], }); realm.objects("Singleton").addListener(() => { throw new Error("Change happened!"); }); } render() { return <View><Text>App loaded ...</Text></View>; } }
Version of Realm and Tooling
- Realm JS SDK Version: 2.6.0
- Node or React Native: React Native (confirmed on iOS)
- Client OS & Version: N/A
- Which debugger for React Native: None