socketio / socket.io-redis-streams-adapter

The Socket.IO adapter based on Redis Streams, allowing to broadcast events between several Socket.IO servers.
https://socket.io/docs/v4/redis-streams-adapter/
MIT License
30 stars 15 forks source link

emit before disconnectSockets #13

Closed SupertigerDev closed 8 months ago

SupertigerDev commented 8 months ago

I have code where I emit before disconnecting the user. However, the User is disconnected before the event is emitted. Is there some kind of await thing i could use for emit?

io.in(opts.to).emit(AUTHENTICATE_ERROR, {
   message: opts.message,
   data: opts.data,
});
io.in(opts.to).disconnectSockets(true);

Notes: • When removing disconnectSockets, the emit function works. • When removing this streams adapter, the emit + disconnectSockets both work perfectly.

darrachequesne commented 8 months ago

I could indeed reproduce the issue, I'm digging into this...

darrachequesne commented 8 months ago

This should be fixed by https://github.com/socketio/socket.io-adapter/commit/a13f35f0e6b85bbba07f99ee2440e914f1429d83, included in socket.io-adapter@2.5.4 (and thus @socket.io/redis-streams-adapter@0.2.0).

Could you please check?

SupertigerDev commented 8 months ago

Seems to be fixed, thanks ❤️