[temp fix] Always delete client YDoc on disconnect #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
yprovider.tsdeletes the client YDoc & stops retrying the connection only when the WS close code is1006. This indicates an unexpected closure (e.g. viakill -9 <PID>). However, our backend should close each WebSocket gracefully before exiting; this sends close code1000, which gets ignored byyprovider.ts. This causes re-connect attempts to fire constantly from outdated clients after the server is restarted.This PR simply removes the
if (event.code === 1006)condition and always deletes the client YDoc & stops retrying the connection on disconnect. This fixes #39 and prevents content duplication when an outdated client connects to a new server session.While this PR does fix the edge cases, it also worsens the experience for users with a flaky internet connection, who now have to refresh the page manually every time they are disconnected. We can improve this in future PRs; I've identified ways to handle client disconnects more gracefully in a new issue: #45.