ably / spaces

The Spaces SDK enables you build collaborative spaces for your application and enable features like Avatar stack, Live cursors, Member location, Component locking and more.
https://space.ably.dev/
Apache License 2.0
43 stars 7 forks source link

Spaces SDK gets stuck after channel is suspended and reconnects #331

Open ajaffie opened 1 month ago

ajaffie commented 1 month ago

I've been trying to fix this bug where users are seeing themselves in a space and other users see that user in the space when they aren't there. I eventually figured out that the bug is caused by the user disconnecting long enough for the connection and channel to be suspended and returning later without refreshing the page. The Ably SDK seems to reconnect fine, and the channel re-attaches, but the space enters an irrecoverable state. I think what's happening is the space is hanging on to the original connection id while the Ably SDK uses a new one. A few pieces of evidence support this:

When trying to leave an affected space, this error occurs: Error: must enter a space to perform this operation. Seems to be caused by calling getByConnectionId with the outdated connection id here

Let me know if there's anything else I can do to help.

VeskeR commented 1 month ago

Hi @ajaffie ! Thank you for bringing this to our attention.

Could you please provide a reproducible example or code samples showing how you are using the Spaces SDK, along with the steps you take to reproduce the issue?