joebobmiles / zustand-middleware-yjs

Zustand middleware that enables sharing of state between clients via Yjs.
MIT License
103 stars 10 forks source link

Fix initial state wipe on join #27

Closed joebobmiles closed 3 years ago

joebobmiles commented 3 years ago

Fixes #26. Turns out that this happens when a user joins too quickly for the existing shared state to be transferred. This means that the code that initialized the map would trigger. Because the changes that "player 2" made were newer than any changes being received, they took precedence and wiped the shared state.

Seems the fix was literally to remove the code. After rewriting some tests to test what they actually were supposed to test and writing a test that replicated the issue, I can now say that this problem has been solved.

joebobmiles commented 3 years ago

There's a problem with the new test I added. It invokes a node script (the Yjs WebSocket demo server) via child_process.spawn. Seems that node is not available when running in GitHub Actions.

joebobmiles commented 3 years ago

:tada: This PR is included in version 1.2.4-rc.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

joebobmiles commented 3 years ago

:tada: This PR is included in version 1.2.5-rc.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

joebobmiles commented 3 years ago

:tada: This PR is included in version 1.2.5 :tada:

The release is available on:

Your semantic-release bot :package::rocket: