-
-
Notifications
You must be signed in to change notification settings - Fork 882
Avoid clients being deleted too early #5422
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
Conversation
|
I'm thinking of a test for this. Meanwhile I'm thinking also, how can we speed up the debugging should it come next time with improvements in the codebase and tooling?
|
|
14a6954 mirrors case 1 in #5119 (comment). Can't manage to do case 2 though, but case 1 is more representative of the original issue ( |
evnchn
left a comment
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.
Tests should pass (I already see test_client_lifecycle.py passing, if you're unsure give it 20 minutes from now). Let's merge this fast.
Bonus items in #5422 (comment) should be non-blocking can be addressed anytime afterwards.
|
Question: Why the dual-mode?
Can we populate a delete task in |
|
@evnchn Interesting idea to get rid of the pruning loop! I'm just a bit concerned about the amount of code change to get it working. Before the first handshake we have no By the way, I wonder if we actually need document IDs now that we don't have shared clients anymore (ignoring PR #5421). So maybe there is even more room for simplification. Anyway, let's leave this PR as it is for now, allowing to merge this critical bugfix. We can try refactoring the client lifecycle in a separate PR. |
|
Other than that, code simplifications are always welcome. In fact I wonder whether getting rid of the 60-second client scanning can get rid of some periodic lag spikes, which I have sometimes noticed with NiceGUI apps 🤔 |
As far as I can tell it's only exchanged between client and server, but not stored as a public member in |
|
But we have https://github.com/zauberzeug/nicegui/blob/main/nicegui%2Fstatic%2Fnicegui.js#L327 Not underscore or anything, straight up in |
|
Ah ok, I didn't consider the JavaScript world as public. At least NiceGUI is trying to hide it from the user as much as possible. But at the same time we encourage to |
|
Hmm why is #5421 is going to be very unreliable as a result, since:
What gives? Possibly due to auto-index client (which never dies) we have flawed-logic from the getgo? 🤔 |
Motivation
This PR finally solves the KeyError described in #5119, which has been silenced in #5090 without understanding the root cause. As it turned out,
Client.prune_instancesfalsely treated reconnecting clients as stale and deleted them. After the client gave up waiting for a reconnect, it got deleted as second time.Implementation
This PR
client._delete_tasks, andif self.id in Client.instancesfrom Lots ofKeyErrorafter Redis connection close fix #5090.This should fix the root cause and stops hiding KeyErrors in case clients are still deleted multiple times.
We could also make
delete()idempotent so that it can be called repeatedly. But as this bug shows, it's better to crash if an assumption doesn't hold than to hide it with too many precautions.Progress
test_user_storage_is_prunedis failing. Why?