-
Notifications
You must be signed in to change notification settings - Fork 582
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
Realm object constructor must not return another value when debugger running #3673
Comments
I have read that this error has been happening in since version v5 and is described here #3007 and #2790 (I have posted this write-up also in the comments there) Also I see that there have been many issues with same title, but all of them are closed and do not provide a working solution for us. If there is a solution somewhere or if you are working on something (I see some threads regarding Hermes) then please just point us to it. |
#3642 discussed the use of class models. I mentioned the issue since Our Chrome Debugger support is brittle. As an alternative, you can use Safari DevTool and attach it to you running app (actually, the JavaScriptCore instance on the simulator or device). |
@kneth Well in comparison to that issue we are not even using any constructors inside of our models and just to add the problem is being thrown even in safari dev tools (not tested with directly attaching to JavaScriptCore instance, I know this wasn't supposed to probably work). If I remove these lines from the mentioned code: if (constructor) {
let result = constructor.call(object);
if (result != null && result != object) {
throw new Error('Realm object constructor must not return another value');
}
} Then it seems to work quite well while debugger is running, but I do not know much about this codebase, so I don't know if it breaks something later on. DecoratorsAnother thing that has been bugging our team is the inability to utilize decorators inside of model properties in v10 (don't know compatibility in other version except in v3 it worked/works): @model("User") // Defines model name and initializes schema - WORKS
class User extends Realm.Object {
// Defines type in schema - Doesn't work because the property becomes always undefined **without debugger**
@property("string?") name?: string;
}
This works only in debugger ... These issue combinations seem to be getting comical to be honest 😆 I know there is an issue #877 already about this, but last activity is 2 years ago and it's only about official decorator support, which I don't need (and I suppose other people as well). The only thing that would be nice would be if the property decorators worked in production and development builds without dev tools. I have seen some investigation about workarounds for this problem in aklinker1/realm-ts-class-decorators#18 (comment), but it has not been resolved. Is there anything that can be done about this situation? |
Closing this as it will be resolved with the support for Hermes and the Flipper debugger. Please see here to try it out and provide feedback. Thanks for your patience! |
Goals
Debugging working with classes.
Actual Results
Steps to Reproduce
Try to access a realm object instance when debugging.
This error seems to be still happening in 10.3.0 - we have just migrated our code to be compatible with the version 10.x.x from 3.x.x and are facing this issue. If we do not use a debugger (RN Debugger, Google Chrome debugger) it works as expected.
Model
Accessing an object instance
lib/browser/objects.js (the error is thrown here)
Console output
Error
Version of Realm and Tooling
The text was updated successfully, but these errors were encountered: