-
Notifications
You must be signed in to change notification settings - Fork 78
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
fix: add cache disabling option #1442
Conversation
Size Change: +601 B (+0.13%) Total Size: 467 kB
|
@isekovanic Is it possible that due to |
@MartinCupela I would say no, since the channel instances do exist and are returned adequately - it's just the cache that is not being populated - meaning the I think that might also be out of scope of the constraints we give to the flag, since this is really only meant to be used as a REST API. What do you think ? |
I realized that the check for being initialized is looking into whether the client is running server-side, so should be ok. |
@isekovanic I think a nice test for this PR would be to run the chat QA tests - the test use both a client-side client and a server-side client as well (code) - but I assume you don't yet have a chat backend set up locally |
I do not, no @szuperaz - would be happy to though |
@isekovanic did you check that we don't add references here: https://github.com/GetStream/stream-chat-js/blob/master/src/client_state.ts#L14-L16 - this is new to me as well, so I might be missing something, but following source code it seems possible that we'll store data even if cache is disabled |
@isekovanic I went through all |
@isekovanic I think we should also make sure that client.mutedChannels and client.mutedUsers are not populated server-side. WDYT? |
@szuperaz sounds good, will do that ! @MartinCupela saw those too, however they only every updated through WS events, which we consider out of scope for this. I could add the flag for brevity but would prefer to not touch too many of these places at once if you don't mind |
PR for chat QA test update: https://github.com/GetStream/chat/pull/7890 |
@@ -296,7 +296,7 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG | |||
// set the key | |||
this.key = key; | |||
this.listeners = {}; | |||
this.state = new ClientState<StreamChatGenerics>(); | |||
this.state = new ClientState<StreamChatGenerics>({ client: this }); |
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.
I am wandering whether it makes sense to even have client.state
when the client is initialized with cache disabled. But that would probably be a breaking change right?
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.
Not necessarily a breaking change, but I guess it's safer this way for now - I guess it's better to have it there in case the client.state
is extended at some point with other things so that we don't have to revisit the stuff here.
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.
Why do we even have a attribute called state
that keeps user cache only 🤦 .
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.
No idea either :D Hadn't fiddled with it before sadly, hence why it took me a while to reverse engineer everything here
CLA
Description of the changes, What, Why and How?
Fixes the issues mentioned in this Zendesk ticket.
Mainly, this flag is meant to be used for a very niche' usecase of the LLC when it's used purely as a REST API on the backend. The issue boils down to a couple of things:
As an example - let us say that we have 10000 users and each user has 5 distinct channels (some group ones, maybe some direct messaging channels etc.). The first time one of these users runs
queryChannels
towards the custom backend (which in turn runsclient.queryChannels
), the entities will end up in bothclient.activeChannels
andclient.configs
until the pod is restarted.On the client side app this works fine because you physically would not be able to query through so many channels given a
userId
.Provided below is a quick summary on why it's okay to do this in a REST API setting:
client.activeChannels
is being used in this setting is here, the rest are either WS event handlers or state dispatchers (none of which we need given the constraints)client.configs
object is only really used to get achannel
configuration in the client-side SDKs, in the case of a REST API they can use theconfig
returned from the HTTP requestpollCache
is something we do not need on the server-side, as again we have other ways to get a poll (and it also comes baked in its own messages)Changelog