-
Notifications
You must be signed in to change notification settings - Fork 577
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 returns blank when not using React Native Debugger #2500
Comments
A new thing I just discovered. The object's method sometimes returns the data as an array and sometimes returns all the data as part of an object. The error occurred because I needed to add a snippet of code that transforms the object that is returned into an array so I could iterate over it and render the items in the list. Funny enough the problem happened because the data was returned as an array, but the snippet of code deleted it. This appears to happen when Realm is executed inside the debugger. Example: {
"0":{
"data": "data1"
},
"1":{
"data": "data2"
}
} So I had to add a snippet of code to turn it into an array like so: [
"0":{
"data": "data1"
},
"1":{
"data": "data2"
}
] When not running the debugger, the data is returned as an array normally: [
"0":{
"data": "data1"
},
"1":{
"data": "data2"
}
] So the snippet of code actually transforms it into this: Which my component then rendered as an empty item on the list. Not sure if this is supposed to happen. This also doesn't seem to be affected by the number of objects being retrieved from the database |
OMG, same here! I have spent more than 3 hours to locate the weird bug ,but have no clue, the only thing I am quite sure is that it is all about trying to retrieve object(objectForPrimaryKey in my case) under or not under the react native “Debug JS Remotely” mode. My app use realm 2.29.2 & react native 0.60.5: After an object with several fields is saved to realm, I use objectForPrimaryKey to retrieve it back,but weird things will happen when objectForPrimaryKey is called,if I turn react native “Debug JS Remotely” on,objectForPrimaryKey will return the right object,but if I turn“Debug JS Remotely” off,objectForPrimaryKey will return a blank object(not undefined). I happened every time with the same result. |
I'm still waiting on a response from the actual maintainers of the repo. Did you try anything else? I just simply stopped using the debugger and started debugging by using alerts all around my code |
@christian-hess-94 @YaoHuiJi Sounds like a bug in the RPC calls between the debugger and the device/simulator. We'll investigate early next week. |
@christian-hess-94 I have found a way to solve my issue , but to be honest I do not know why.....here is something I've found, not sure if it's helpful for you . In my last comment, I said if “Debug JS Remotely” is turned on, objectForPrimaryKey will return the right object('yes'), if it's turned off will return a blank object('no'), looks like this
but actually , code like this works fine, the output will always be 'yes' not matter debugger is turned on or off. the code with weird bug actually looks like this:
I use Object.assign to copy data into my own object, but weird things happened then, in debug mode, it will copy data as expect, but if debug mode is off it will copy nothing, just an empty object. I have googled some issue about Object.assign, like 2282,2282,1299 , but they are all not answered too. I guess maybe it's about javascript runtime? when 'Debug JS Remotely' is turned ON, the code is running in V8, when it's turned off, the code is running in JavaScriptCore, maybe Object.assign in these two runtimes has different behavior?It was just a shot in the dark, I totally have no idea why it's so weird😫 |
@YaoHuiJi Thank you for investigating. |
this issue is still remain, I'm using Objects.find as a workaround.
|
So I had the same issue as well. I was able to resolve it by following these steps:
** If you get an error that looks something like this:
Hope this helps! 🙂 |
@havi-b Thanks for the description. One note: you should be able to do it without changing the |
@blagoev Ahh it seems you are right. This saves a lot me some work. Having to go into the module and add the override is pretty annoying 😅. |
Same issue here also guys! Thank you @havi-b and @blagoev for this workaround, but it didn't work for me. So I have to downgrade my Realm to version 3.6.5 (npm i --save [email protected] or yarn add [email protected]). After those objects() and objectForPrimaryKey() functions return to work fine. I think this 5.x.x and 4.x.x (beta) versions are broken for React Native! |
Working correctly: export class RealmPlayLog extends Realm.Object { ... |
I'm not using any debugger at all and experiencing the same issue. @samuelrvg extends from |
|
@manoj-makkuboy in [email protected] you should be able to use |
@steffenagger |
@manoj-makkuboy if you are using class models, please try extending from class MyModel extends Realm.Object {
...
} |
@steffenagger I tried it and it worked. Thank you |
Eu criei meu schema como uma constante ao invés de class e funcionou perfeitamente const Schema = { export default Shema; verão do react-native: 0.63.2 |
Unfortunately can confirm that we are still facing the same issue even in the newest version of realm. We have to still use the realm version 3 |
I'm running realm
When debugging, the realm object logs when not debugging, any subsequent fetches such as These issues go away when react-native has "Debug remote JS" enabled I'm trying to import several polyfills at the start of my RN project, but no luck so far. |
@kneth Any updates on this? I seem to be seeing the same issue as @nicotroia with similar versions. We're currently running React Native 0.64.1 with Realm 10.4.1. On both android and ios, we see an array with our full schema in the realm object This problem only occurs the first time the app is launched on the device. If we refresh the app, either by changing the code or refreshing the simulator, the schema and realm objects are returned properly. This also does not occur if we are running the Chrome debugger at the same time although I think that's just because the debugger forces a refresh when you enable it. |
@rjberry95 We released v10.4.2 today, and we have a fix for reloading the app on Android (see also #3668). From your description, v10.4.2 might not solve it. Have you observe a similar behaviour with other versions of React Native? |
@kneth Thanks, I tested 10.4.2 today, and unfortunately, it did not solve our problem. I've tested this with React Native versions 0.64.1 and 0.64.2. I have not gone any lower than that since those are the latest versions. Is there a specific version of react native that we should be using? |
@rjberry95 Thanks for your feedback. We are using an unconventional approach to hook into Javascript Core, and my best hypothesis is that recent RN versions will require some adjustments. |
After a day of trying to get realm to work with a fresh react-native app, we've abandoned all hope. Best fix for this 2 year old issue is:
|
I have a same issue with latest realm version and RN 0.64 |
in combination with |
Same issue here. Latest realm, RN 0.63.2 |
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! |
Still facing the issue for react native 0.68.0 version. Issue is particularly for android platform in react native. Realm.open is retuning empty object when chrome debugged is off. I am using react native 0.68.0, realm version "10.9.0". And I should not use hermes as I have some dependencies in other project. |
It is possible to use JSC with our latest releases. Of course, in order to use debug, you will need to use Flipper and Hermes. We are not fixing any bugs in the support for the Chrome Debugger as it is too slow to be used in any practical cases. |
but we not using hermes. It is working fine when chrome debugger is turned on but when it turns Off it is returning empty object. @kneth , Can you try once with the blow versions on android platform without chrome debugger turned on. react native 0.68.0, |
@kneth I wanted to see realm working fine for android platform with react native 0.68.0 only. And any of the realm version is fine. Please suggest. |
If you do |
@kneth I am doing the same. please see the below screenshot. |
@gopi-hrbl-c I would like to know what you are looking for with |
@kneth , Yes instance.path is returning string. But I am not able to see the log of instance.objects('CustomerValidation'), I want to see the result from instance.objects. Please observe the below screenshot there is no log for CustomerValidation. As you said I can see instance.schema but instance.objects('CustomerValidation') is returning nothing. It is just throwing from that line and I am not able to catch it what is the error even by using try catch. |
Goals
I'm trying to add an entity into Realm and then read and list it in another scene.
Expected Results
The data that is read is supposed to be rendered as a list. It does happen but the data itself is not present.
Actual Results
The data is saved to the database and is subsequently read from the database. A single item is rendered to the list, but all its values are empty. When clicking the item, a new screen opens which showcases all the data from that specific item (the item itself only shows 2 of the details)
This only happens if I'm not running the React Native debugger. I've generated the debug APK for testing purposes and the error still persisted.
Steps to Reproduce
I'm not sure what can be done to reproduce this. I'm saving one item to a schema and later reading it. The data is retrieved but all the values in it are empty.
Code Sample
1.This is the code that reads the data from the database. None of the values are undefined or null. This return the blank data when not using the debugger:
Version of Realm and Tooling
The text was updated successfully, but these errors were encountered: