-
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
Records created with a previously deleted ID generates an uncaught error #145
Comments
Could you share the code you're using to authenticate users with Anonymous Auth? |
I can confirm this, a record removed on the server will also remove locally, but the deleted record will still be cached locally in the store. This is because we use On the client that deletes the record, as long as you use post.get('id'); // -Jm0LzWtETCIw-LT9ZUP
post.destroyRecord().then(function () {
store.recordForId('user', '-Jm0LzWtETCIw-LT9ZUP'); // undefined
}); But on a different client that observed the delete from the server, the deleted record is still there: // -Jm0LzWtETCIw-LT9ZUP was deleted on server
store.recordForId('user', '-Jm0LzWtETCIw-LT9ZUP'); // returns the deleted (hidden) record
store.createRecord('user', { id: '-Jm0LzWtETCIw-LT9ZUP', ... });
// Assertion Failed: The id -Jm0LzWtETCIw-LT9ZUP has already been used with another record of type dummy@model:user:. The workaround is to find the record and unload it manually before creating: store.recordForId('user', '-Jm0LzWtETCIw-LT9ZUP').unloadRecord();
store.createRecord('user', { id: '-Jm0LzWtETCIw-LT9ZUP', ... }); // works |
@tstirrat For the case where there is a different client observing only, how can I manually unload the record? On some other client, a record with a previously used ID is pushed, the observing client receives the Firebase event and attempts to push the new record (with a re-used ID) into the store, but this is all happening within the emberfire codebase - how can I apply this workaround in my app? And why not use |
@jamiechong Not sure I understand, why does your client have a record with duplicate id in its store if things happened via another client? can you elaborate? |
And yes, we should really be doing |
@tstirrat Sure. Say I'm saving unique records by explicitly setting the
|
Also note that I did try replacing |
cool, thanks for clarifying that, yes that is a problem |
I wonder if |
@tstirrat I think
However, unloadRecord only works for non-dirty records so if UI-B is able to change the record before it's informed about the destroy event, it will fail. Perhaps delete, then unload or unload if delete fails? |
I'm inclined to say that using only The one potential issue, as raised in #322, is that afaik just calling |
In my application, I have what I think is a fairly standard
User
model, whose IDs are based on the authenticated users'fbRef.getAuth().uid
value (which in my case is assigned by the Anonymous authentication provider). I have a global users which dynamically updates as users authenticate/unauthenticate, that is populated using a basicthis.store.find('user')
call.The problem arises when a user signs out, and then re-authenticates/signs in with the same auth uid. I recieve the following error in the consoles of the other currently connected browsers:
(note however, that the user/browser that did the signing out/re-logging in receives no error)
Is there anything else I need to do in this scenario to make sure that records automatically deleted by emberfire are fully committed in each connected client's cached store, or is this a limitation of some sort?
For reference, here is how I am creating the records when a user signs in:
And when they sign out:
The text was updated successfully, but these errors were encountered: