-
Notifications
You must be signed in to change notification settings - Fork 584
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
linkingObjects results in recursion in debug mode #1532
Comments
Thank you for reporting and taking the time to debug. We need to write a test to reproduce it and fix it. |
@YaoHuiJi I think that I am getting the same bug as you. In debug mode the main thread freeze and if I compile in Release my Redux actions aren't triggered anymore. In both case the app doesn't respond properly. @kneth Here are the two schema involved:
Interaction has a collection of User via Version of Realm and Tooling
|
@StevenMasini Can you describe the operations which causes your Redux actions not to trigger? Can https://github.com/lolatravel/realm-react-redux or https://stackoverflow.com/questions/40167038/using-realm-in-react-native-app-with-redux help you? |
@kneth Thank for your answer. I don't know if For now, in order to move forward on my project, I just changed the After I am not sure what was blocking my Redux actions to trigger, but it seemed like an infinite loop. |
@StevenMasini We are eager to hear how it goes when you are using |
This bug has the tag "Reproduction Required": It would be nice if this gets fixed. |
The default way to serialise an object to JSON will print all properties. Since a realm object with a link also has a backwards link (the linkingObject property) the JSON.stringify() (and probably the react debugger) will hit a recursive loop when printing a realm object. We could potentially provide a version of toJSON() on Realm objects which only prints the forward links but I'm not sure if it would be annoying for debugging not being able to see the linkingObjects property - it would be better than crashing in a stack overflow though. |
No, I don't think so. |
This also stops me using reactotron, reactotron sending stringify results to reactotron server, but my realm object contains such recursive relationships. |
hi, in my app I use realm.objects to get some data, if I turn off the 'Debug JS Remotely' on iOS simulator, everything works fine, realm.objects will return my data. but if I turn on 'Debug Js Remotely', the 'get_property' will be called more than 25000 times until the error ' RangeError: Maximum call stack size exceeded' be thrown, see the screenshot below:
after added some debug codes, I found out It seems like the problem is about 'linkingObjects'. my schema looks like that:
class Goal {
static schema = {
name: 'Goal',
primaryKey: 'id',
properties: {
id: {type: 'int'},
title: 'string',
kpis: 'Kpi[]',
}
}
}
class Kpi {
static schema = {
name: 'Kpi',
primaryKey: 'id',
properties: {
id: {type: 'int'},
title: 'string',
goals: {type: 'linkingObjects', objectType: 'Goal', property: 'kpis'},
}
}
}
I go through thousands of 'get_property' requests, and found out that Goal and KPI will call each other recursively, goal.kpis->kpi.gols->goal.kpis->kpi.goals and on and on until 'Maximum call stack size exceeded'. If I turn off the debugger, the recursion is gone, or If I remove the linkingObjects 'goals' of KPI schema, the recursion is gone too.
sorry for my poor english, if It's not clear enough ,please let me know.
Version of Realm and Tooling
The text was updated successfully, but these errors were encountered: