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

Add ReliableWebsocketProvider to JavaScript module #25

Open
eliias opened this issue Feb 6, 2023 · 0 comments
Open

Add ReliableWebsocketProvider to JavaScript module #25

eliias opened this issue Feb 6, 2023 · 0 comments
Labels
enhancement New feature or request javascript Pull requests that update Javascript code

Comments

@eliias
Copy link
Collaborator

eliias commented Feb 6, 2023

Problem

A reliable channel ensures at-least-once guarantees via acknolwedge messages sent by both, client and server. Therefore, the client, and the server must reliably store messages that weren't acknowledged by all recipients yet. In case of the client, this means the server must respond with a last-ack-id response when messages are sent, and the client must always send the full message queue to workaround missing “in-between” updates.

Implementation

The default WebsocketProvider does not support message buffers and acknowledgment of messages. The ReliableWebsocketProvider is therefore a drop-in replacement that takes on the additional responsibilities of transparently managing a send buffer, and acknowledging message retrieval.

Due to Y.js supporting staging of messages (messages are not integrated until all necessary messages are available), and applying updates being idempotent, this isn't an issue.

sequenceDiagram
Client->>+Server: Send message buffer to server
alt no response
  loop Retry (w/ exponential backoff)
        Client-->>Server: Send message buffer
  end
else
  Server-->>-Client: Acknowledge message retrieval
end
Loading

Caveats

We aim for eventual consistency (at-least-once delivery), and similar transport latency as with the regular WebsocketProvider on the happy path (exactly-once delivery). There is a chance of transmitting messages twice, when an “older” message wasn't transmitted, but the client is producing “new” messages.

@eliias eliias added enhancement New feature or request javascript Pull requests that update Javascript code labels Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code
Projects
None yet
Development

No branches or pull requests

1 participant