We first call:
sendbird.disconnect()
and then serverside, we delete the user completely (though that may be irrelevant to this issue).
Back in our app, when we later call
const sendbird = SendBird.getInstance()
sendbird.currentUser
is still populated with most of the user’s original values! I would assume currentUser would go to null after calling disconnect, but apparently, this is not the case. Because of these misleading values, to our code, it looks like the user is currently logged in, and we proceed to call createMyGroupChannelListQuery()
, which causes the error SendBirdException: User has been deleted.
How can we check a SendBird instance to know if the currentUser object is connected or not? As a final summary, observe the following code:
// get sendbird instance
const sendbird = SendBird.getInstance()
// disconnect this user
await sendbird.disconnect();
// as sanity check, get instance again and log out currentUser object
console.log(SendBird.getInstance().currentUser)
This logs out:
{"_preferredLanguages": [], "connectionStatus": "nonavailable", "friendDiscoveryKey": null, "friendName": null, "isActive": true, "lastSeenAt": 0, "metaData": {}, "nickname": "", "plainProfileUrl": "", "requireAuth": false, "userId": "2333cdf54fc69a0e"}
Still even showing the userId
!