Skip to content
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

Suspicion of two concurrent room unsubscribes on client disconnect #2541

Open
psam44 opened this issue Jul 7, 2024 · 1 comment
Open

Suspicion of two concurrent room unsubscribes on client disconnect #2541

psam44 opened this issue Jul 7, 2024 · 1 comment
Labels

Comments

@psam44
Copy link

psam44 commented Jul 7, 2024

Consider this client scenario (even if not regular):

const ws = new WebSocket("...", { port: ... });
const kuzzle = new Kuzzle(ws, ...);
await kuzzle.connect();
await kuzzle.auth.login("local", ...credentials...);
await kuzzle.realtime.subscribe("...index...", "...collection...", {}, ...callback...);
kuzzle.disconnect()

An error appears in log:

{"level":"error","message":"2024-07-04 09-46-45 [LOG:ERROR] [knode-sarcastic-shannon-82790]
 PreconditionError: User \"ec...14\" has not subscribed to \"2d...ef\"."}

Reading the sources, I guess this may be an explanation:

  • core.auth.TokenManager has a listener on("connection:remove", ...)
    -> removeConnection(...)
    -> expire(...)
    -> ask("core:realtime:connection:remove", ...)

  • core.realtime.HotelClerk has also a listener on("connection:remove", ...)
    -> removeConnection(...)
    -> unsubscribe(...)
    and a listener onAsk("core:realtime:connection:remove", ...)
    -> removeConnection(...)
    -> unsubscribe(...)

This leads to two calls to unsubscribe(). One is run correctly, and empties connectionRooms at some time.
The other one would progress enough meanwhile, but fail at the check for a non empty connectionRooms, so:

throw realtimeError.get("not_subscribed", connectionId, roomId);
@psam44 psam44 added the bug label Jul 7, 2024
@rolljee
Copy link
Contributor

rolljee commented Jul 31, 2024

Hello and thank you for your analysis on this issue, we will have a look into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants