-
Notifications
You must be signed in to change notification settings - Fork 447
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
Ignore doc does not exist on presence destroy #381
Conversation
When we destroy local presence, we attempt to update the presence to `null` for remote clients as part of the cleanup. However, if we delete a doc, and then destroy the associated presence, the presence attempts to send a message on a deleted doc, which returns an error. Let's just ignore this error. There's no need to reset presence on a deleted doc, because remote clients will [already assume it's `null`][1]. [1]: https://github.com/share/sharedb/blob/a81e2c99af77da12885f0fa860e87cc2602a6cc1/lib/client/presence/local-doc-presence.js#L90-L96
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LocalPresence.prototype.destroy.call(this, function(error) { | ||
// If the doc does not exist, let's just ignore the error. There's no need to | ||
// tidy up presence on a deleted doc. | ||
if (error && error.code === ERROR_CODE.ERR_DOC_DOES_NOT_EXIST) error = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, doing the skip here means that if !this._doc.type
(the check in LocalDocPresence.prototype.submit
), the LocalPresence.prototype.destroy.call
could have been replaced with a short-circuit.
But you said that you wanted the cleanup here to still run:
delete presence.presence.localPresences[presence.presenceId]; |
So the update to instead not emit an error in LocalDocPresence.prototype.submit
if the value is null
seems good. Or short circuit.
This change amends the `destroy` logic for `LocalDocPresence`, which handled the error in the wrong place, and meant that the `LocalPresence` would not correctly tidy up the reference to the destroyed local doc presence. This change adds a check to `LocalDocPresence.submit`. If we're submitting `null` on a deleted doc, we just immediately return, since the remote client will already assume a `null` presence in this case.
e002dab
to
37d35f0
Compare
When we destroy local presence, we attempt to update the presence to
null
for remote clients as part of the cleanup.However, if we delete a doc, and then destroy the associated presence,
the presence attempts to send a message on a deleted doc, which returns
an error.
Let's just ignore this error. There's no need to reset presence on a
deleted doc, because remote clients will already assume it's
null
.