Randomly getting 'User is not a member' error

hey guys,
I keep getting the following issue randomly
Message LiveCollections can not query/get/sync data from server EkoSDKError: EkoSDK: User is not a member of this channel 609be9cdbe4c3c8da9032887
on the web sdk
the userId is a new one and the channel type is live
My setup at the moment is everytime I refresh the page (intentionally) I create a random userId
I have opened 3 browsers and every so often I refresh one of the browsers to emulate a new user entering and an old one not being there any more.
Do you have any idea why this error keeps appearing?

Hi @touchaponk !

Thank you for reporting! Looking at the situation you described and the error you reported it’s most likely you’re trying to fetch messages of a channel before having joined it.

Please, try to make sure you’re having a confirmation that the user joined the channel before fetching messages. For the quick fix, please try to add boolean flag inside callback of “dataUpdated” event:

let isJoined = false;
const liveChannel = new ChannelRepository().joinChannel(...);
liveChannel.once("dataUpdated", channel =>isJoined = true);

Otherwise, if you wish for a more accurate response, you’d have to check for the membership of the user after they joined the channel:

let isJoined = false;
const liveMembership = (new ChannelMembershipRepository(channelId)).myMembership;
liveMembership.once("dataUpdated", ({ membership })=> {
    isJoined = membership === ChannelMembership.Member;
});

Please let me know if this works for you!

I am looking forward for your reply!