question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

linkingObjects results in recursion in debug mode

See original GitHub issue

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: image

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:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ouabingcommented, Feb 12, 2019

This also stops me using reactotron, reactotron sending stringify results to reactotron server, but my realm object contains such recursive relationships.

2reactions
TheNoimcommented, Sep 10, 2018

This bug has the tag “Reproduction Required”: Here you go: https://github.com/TheNoim/realm-recursion

It would be nice if this gets fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I debug my recursive function that's causing stack ...
good question. First, I think that a recursive solution isn't ideal here. I got it working for the inputs you gave, but considering...
Read more >
Realm: Create reactive mobile apps in a fraction of the time
AnyRealmCollection , a type-erased class that can forward calls to a concrete Realm collection like Results , List or LinkingObjects .
Read more >
Assign3: Testing and debugging recursive functions
Run the program in Debug mode. When prompted, select the tests from warmup.cpp to run. When stopped at the breakpoint, the lower middle...
Read more >
How to debug stack frames and recursion in GDB
Using the up command, we can look around frame #1 (moving "up" the call stack) as if the code was stopped there instead...
Read more >
Debugging Recursion - YouTube
Huw Collingbourne is the author of The Little Book Of Recursion :http://bitwisebooks.com/books/little-book-of- recursion / Recursion is a vital ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found