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

[Full-stack Signals] Add automatic resynchronization #2653

Open
platosha opened this issue Aug 13, 2024 · 6 comments
Open

[Full-stack Signals] Add automatic resynchronization #2653

platosha opened this issue Aug 13, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request hilla Issues related to Hilla

Comments

@platosha
Copy link
Contributor

platosha commented Aug 13, 2024

A signal instance that has subscribers will automatically resynchronize with the server when the client reconnects to the server after having been disconnected. While disconnected, the signal value remains set to the value that was last seen before going losing the connection, supplemented with latency compensation for any pending operations. Pending operations that have been performed while disconnected will be sent to the server when the connection is restored (assuming the same client-side instance is still in active use).

const counter = CounterService.counter();

effect(() => console.log("Value update:", counter.value));

addEventListener("offline", () => {
  console.log("Value when going offline:", counter.value);
  
  // Will be logged immediately thanks to latency compensation but delivered to the server only when connectivity is restored
  counter.incrementBy(1);
});

addEventListener("online", () => {
  // Nothing to do here since any change from the server hasn't yet been retrieved but that will happen soon
});

Note that the implementation should also recover from network connectivity issues that cause the connection with the server to be broken even though the browser fires no offline and online events.

@platosha platosha added hilla Issues related to Hilla enhancement New feature or request labels Aug 13, 2024
@platosha
Copy link
Contributor Author

Workflow notes:

  • Any changes on the client are considered happening after any changes from the server. The server acts first.
  • We should never rewrite history. After the server confirms the change, the order is never changed.

@platosha
Copy link
Contributor Author

platosha commented Aug 13, 2024

Note that every operation result is a custom thenable object.

Edit: Extracted to #2712.

@Legioth
Copy link
Member

Legioth commented Sep 9, 2024

Some parts of this issue have been extracted to separate tickets so that the core reliability feature can be implemented more easily:

@platosha
Copy link
Contributor Author

Note: reusing Flux is not in the scope of this ticket. We assume here that the server has disposed the Flux instance.

@platosha
Copy link
Contributor Author

For now, let us drop the concept of buffering the outgoing operations. At the same time, we have no guarantee yet on wether the outgoing operations were received by the server or not. We'll come back to this when we have a proper event log.

@Legioth
Copy link
Member

Legioth commented Sep 11, 2024

Buffering operations and making sure they are delivered exactly once is now described in #2721.

@cromoteca cromoteca self-assigned this Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hilla Issues related to Hilla
Projects
None yet
Development

No branches or pull requests

3 participants