linkingObjects results in recursion in debug mode
See original GitHub issuehi, 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
- Realm JS SDK Version: 2.0.2
- React Native: 0.50.1
- Client OS & Version: macOS 10.13.1
- Which debugger for React Native: React Native Debugger
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:10 (4 by maintainers)
Top GitHub Comments
This also stops me using reactotron, reactotron sending stringify results to reactotron server, but my realm object contains such recursive relationships.
This bug has the tag “Reproduction Required”: Here you go: https://github.com/TheNoim/realm-recursion
It would be nice if this gets fixed.