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

Race conditions when reconnecting #108

Open
lgrahl opened this issue Sep 26, 2018 · 0 comments
Open

Race conditions when reconnecting #108

lgrahl opened this issue Sep 26, 2018 · 0 comments
Assignees

Comments

@lgrahl
Copy link
Member

lgrahl commented Sep 26, 2018

A WebSocket close is not immediate. We should return a Promise, wait for the close event and then resolve. However, the main problem is that we allow to .connect immediately after a .disconnect which results in racy behaviour as both WebSocket connections are bound to the same event handlers.

This would be a major change and requires significant refactoring. For now, applications should always either:

  1. Wait for the connection-closed event, or
  2. Unbind all events after a .disconnect, throw the SaltyRTC instance away and create a new one. Even if you do this, be prepared to see log messages from previous connections (I'm working on removing this).
@lgrahl lgrahl changed the title Disconnecting should be asynchronous Race conditions when reconnecting Sep 26, 2018
lgrahl added a commit that referenced this issue Sep 26, 2018
Main use case is suppressing further log messages from old WebSocket
connections when the application has already discarded it. The main
problem of #108 remains unresolved (race condition).
lgrahl added a commit that referenced this issue Sep 26, 2018
Main use case is suppressing further log messages from old WebSocket
connections when the application has already discarded it. The main
problem of #108 remains unresolved (race condition).
lgrahl added a commit that referenced this issue Sep 27, 2018
Main use case is suppressing further log messages from old WebSocket
connections when the application has already discarded it. The main
problem of #108 remains unresolved (race condition).
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

No branches or pull requests

1 participant