-
Notifications
You must be signed in to change notification settings - Fork 263
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
Loss of Data - belongsTo disappearing #364
Comments
Does this happen when you delete a record locally? there is some code that tries to remove orphan hasMany links from the server on delete. Could this be it? |
@tstirrat no not during delete (I think). I believe it is happening when I am debugging a save after an edit and the browser is stopped at a |
Ahh, yes, it could be related to us saving relationship links in subsequent requests. This will be fixed in #337 |
Well that is good. This seems like such a big issue I am surprised (and thankful) no one else has hit it :-) |
I wonder if this is related to #367 where the the belongsTo is nullified due to some inverse relationship sync issue, and when you save the model it deletes the belongsTo key. Does that ring a bell? are you updating a hasMany and the later realizing the inverse belongsTo is |
I'm running in to
If I create a keyboard, persist it, then create a photo, persist it then try to link it to a keyboard it all falls apart.
The above results in I've tried Now, if I define I may just end up using a |
Looks, it is a real issue, I have the same problem with belongsTo, hasMany. Firebase randomly remove relations, so data will be inconsistent. It is happening with async: true or without async also. |
I ended up using a |
I solved it with manually remove the previous relationship and adding the new one after. saveAuthor(author, book) {
book.get('author').then((previousAuthor) => {
previousAuthor.get('books').then((previousAuthorBooks) => {
previousAuthorBooks.removeObject(book);
previousAuthor.save();
});
});
// Setup the new relation
book.set('author', author);
book.save().then(() => author.save());
book.set('isAuthorEditing', false);
}, Working demo: https://library-app.firebaseapp.com/books |
@ewalti @zoltan-nz can someone make a MCVE for me, so I can investigate? Thanks. |
@tstirrat http://emberjs.jsbin.com/juwasa/edit?html,js,output Start playing with Author names, change them with the select box (after select, they will saved immediately). |
Are there any news on this issue? |
@florathenb can you post the two models? Brendan |
task: activity: }), numericID: function(){ let id = this.get('id'); if (id) { return +id; } }.property('id'), prio: function(){ let prio = this.get('priority'); if (prio != null) { return +prio; } else { return 99; } }.property('priority'), }); losing the relation from activity to task |
In my person model I have this: In my organization model I have this: You don't have any inverse relationships setup but if you never need the ACTIVITY within the TASK that is likely OK. I am not sure on async: true I thought that was still a requirement although it is supposed to be the default. If this helps here is what I am doing where I have no loss. When a person logs in I load all of their organizations. When they add or edit an organization I save both sides the following way in my org-editor component:
@florathenb I hope that helps. |
problem is, i lose the relation allthough i am not even changing or saving anything.. @brendanoh thanks for the answer anyway!! |
I am not sure I understand what " i lose the relation although i am not even changing or saving anything." means. At some point you need to save the data in firebase, then you see it in the firebase console but later when you load the activity the taskId is gone? What is the ROUTE doing that could remove the belongsTo? Is it reloading either TASK or ACTIVITY? |
Been away due to family emergency. Finally getting back into things. Often when you unexpectedly lose (or gain data) in the relationships on the client side without saving any data, it is usually from one of two things:
A real world example: I have a chat structure where a user has Without setting I hope this helps you narrow down what might be happening in your case. The moral of this story is: Try setting all of your relationships to |
Interesting, I have a (similar?) issue where the users in my db get deleted for no apparent reason. This happens sparsely/randomly and by looking at sentry logs I can see it happening right after a login, where a "no record found" error will pop. The user model in my project has all the entities belonging to him and he as an entity belongs to no model, also all the relationships are inverse: null .. I tried recreating the issue by spamming the login with logins/outs but nothing, i also tried many other stupid/random things someone could do, again nothing. We used to think that this error occurred only after a new deployment where a user wouldn't refresh his page and things would go wrong, but it seems that this is not the case.
The login code is as follows
and the logout
I was forced to do this weird I don't know if everything done here is correct, or best practice, but our knowledge about emberfire grew as the project was being developed. Should i post this here or create another issue maybe? |
@frcake EmberFire has changed dramatically since my last issue of this type so I am not sure if this issue will help you in figuring your issue out.
What does your user model look like? |
@brendanoh thanks for the fast response! I too found it weird and difficult to overcome the errors on logout, others have the same issues too like https://stackoverflow.com/questions/38085030/closing-an-emberfire-torii-session-and-logging-out-throws-permission-denied-erro (now that i see this post again, there's a newer answer, i might check that out too) here's my user model
All in all, it's very strange when things work nicely 99% of the time to have that weird errors pop out and delete an entity from the firebase ?! An exception would look like this
There are also some other similar errors that originate from other routes now that i check again, pfff major headscratcher..! |
So I am having an issue for the 2nd time on an Emberfire project. Last time was almost a year ago when I was putting together a meetup preso on building a chat client in Ember and Firebase.
I have model's with belongsTo relationships and during local debugging the belongsTo keys in forge disappear and my relationship is gone.
I cannot reproduce it and it feels like it only seems to happen during heavy local debugging but it has happened half a dozen times times or so on this recent project so I feel confident it is real and not in my head.
I have found Angularfire issues posted with potentially similar data loss problems but none in this repo. And they all seem related to use of FB internals that I do not touch.
I am wondering if anyone else has experience this as it is very frustrating.
The text was updated successfully, but these errors were encountered: