-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Server is not cleaning up namespaces after client is rejected in middleware. #4772
Labels
bug
Something isn't working
Comments
This was referenced Jul 19, 2023
This is indeed a bug, thanks for the detailed report 👍 |
darrachequesne
added
bug
Something isn't working
and removed
to triage
Waiting to be triaged by a member of the team
labels
Jul 19, 2023
@darrachequesne thank you for your response. If you are able to nudge me in the right direction, I am more than happy to open a PR. I tried something like this, but that seems to make some tests unhappy:
|
5 tasks
Took a jab at this #4773 |
darrachequesne
pushed a commit
that referenced
this issue
Jul 21, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello team! 💜
Describe the bug
When using SocketIO with adapter (namely redis adapter in my case) and dynamic namespaces, the namespace isn't cleaned up when SocketIO server throws an error in middleware.
I believe this is a continuation of a fix @stevebaum23 previously made here: #4602
The new flag
cleanupEmptyChildNamespaces
is cleaning up namespaces when last client disconnects gracefully. It is however not cleaning up properly when client is rejected in middleware.To Reproduce
Socket.IO server version:
4.7.1
Server
Socket.IO client version:
4.7.1
Client
Expected behavior
In the server code, I have a middleware that allows the client to connect 50% of the time (at random). The client's only job is to connect and disconnect straight away.
When observed on redis (using e.g.
redis-cli
andMONITOR
command), when client connects and gracefully disconnects, the Redis namespace is cleaned up (we observe subscribe and unsubscribe events):when however the server rejects the client in middleware using
next(new Error('not allowed!'))
, the redis subscription is made, but is never cleaned up:What seems to be happening is that when we call
next(new Error('not allowed!')
in a socketIO middleware (as suggested in docs), socketIO lib calls_cleanup
on error hereNote that, at this point, redis-adapter is already subscribed to topics in Redis. Thus I believe a cleanup similar to the one in _onclose should happen.
Are you able to assist, please?
Platform:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: