Skip to content

Fix presence:leaving not firing on disconnect due to socket.rooms Set change#7

Open
Oha-you wants to merge 1 commit into
AbdoPrDZ:mainfrom
Oha-you:fix-disconnecting
Open

Fix presence:leaving not firing on disconnect due to socket.rooms Set change#7
Oha-you wants to merge 1 commit into
AbdoPrDZ:mainfrom
Oha-you:fix-disconnecting

Conversation

@Oha-you

@Oha-you Oha-you commented Mar 20, 2026

Copy link
Copy Markdown

Hey there!

Thanks for creating and maintaining this fork. I found it very useful even in 2026. I was able to run it with the latest versions of Socket.IO and Laravel Echo without issues.

Specifically:

  • socket.io@4.8.3
  • socket.io-client@4.8.3
  • laravel-echo@2.3.0 (planning to update to v2.3.1)

While testing, I ran into two small issues that required fixes. This pull request addresses the first one.

Clients remained in presence channels even after closing their browsers. This appears to be caused by a breaking change introduced in Socket.IO v3, where socket.rooms was changed from an object to a Set. As a result, the presence:leaving event was not being triggered correctly.

While it's possible to work around this on the client side using a beforeunload event listener and calling window.Echo.leave, this approach is not fully reliable. For example, it does not handle cases where the browser process is terminated manually (e.g., via Task Manager).

This patch ensures that disconnects are handled properly on the server side, restoring correct presence behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant