-
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
Events before disconnection dropped #5213
Comments
Hi! Unfortunately, I wasn't able to reproduce the issue: https://github.com/socketio/socket.io-fiddle/tree/issues/socket.io/5213 Either with The |
@darrachequesne Thanks for setting up the fiddle. I just cloned it and visited the index.html page. The logs on the server are as follows:
The |
Yes it is:
Ubuntu 22.04, Node.js |
|
Maybe easier to reproduce in a container
|
Ping @darrachequesne , thoughts on this ? |
Describe the bug
In a Socket.IO application, events emitted just before a client disconnects are not properly handled by specific
on(...)
listeners. While theonAny(...)
listener detects these events, the specificon(...)
listeners do not. This issue occurs with any event emitted just before disconnection. The reasononAny(...)
works is that it runs before the dispatch, which relies onprocess.nextTick
.To Reproduce
Socket.IO server version:
4.x.x
(replace with your version)Server
Socket.IO client version:
4.x.x
(replace with your version)Client
Expected behavior
The
on
listener for any event (e.g.,exampleEvent
) should detect and handle the event before disconnection. Currently, theonAny
listener detects the event, but the specificon(...)
listener does not. This occurs becauseonAny
runs before the dispatch, which relies onprocess.nextTick
, allowing it to detect the event before disconnection, seesocket.io/packages/socket.io/lib/socket.ts
Lines 559 to 575 in 175a2c5
Platform:
Not relevant
Additional context
This issue affects any event emitted just before disconnection. The
onAny
listener works because it operates before the event dispatch process, which usesprocess.nextTick
. As a result, events are detected byonAny
but missed by the specificon(...)
listeners, which rely on the dispatch mechanism that happens after disconnection begins.The text was updated successfully, but these errors were encountered: