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

📝 Update docs around reconnecting-websocket #608

Merged
merged 1 commit into from
May 2, 2023

Conversation

alecgibson
Copy link
Collaborator

In our docs, we recommend using reconnecting-websocket to handle websocket reconnection.

However, by default that library will buffer messages when its underlying socket is closed, which can lead to undefined behaviour when ShareDB reconnects, since it works under the assumption that all messages sent as the socket is closing have been lost (eg pushing inflight ops back onto the pending queue, etc.).

This change updates our documentation and our examples to set {maxEnqueuedMessages: 0}, which disables this buffering, and should help to avoid ShareDB reaching undefined states when reconnecting using this library.

In our docs, we recommend using [`reconnecting-websocket`][1] to handle
websocket reconnection.

However, [by default][2] that library will [buffer][3] messages when its
underlying socket is closed, which can lead to [undefined behaviour][4]
when ShareDB reconnects, since it works under the assumption that all
messages sent as the socket is closing have been lost (eg pushing
inflight ops back onto the pending queue, etc.).

This change updates our documentation and our examples to set
`{maxEnqueuedMessages: 0}`, which disables this buffering, and should
help to avoid ShareDB reaching undefined states when reconnecting using
this library.

[1]: https://www.npmjs.com/package/reconnecting-websocket
[2]: https://github.com/pladaria/reconnecting-websocket/blob/05a2f7cb0e31f15dff5ff35ad53d07b1bec5e197/reconnecting-websocket.ts#L46
[3]: https://github.com/pladaria/reconnecting-websocket/blob/05a2f7cb0e31f15dff5ff35ad53d07b1bec5e197/reconnecting-websocket.ts#L260
[4]: #605
@coveralls
Copy link

Coverage Status

Coverage: 97.507%. Remained the same when pulling 3e1e7f0 on reconnecting-socket-docs into c1f1474 on master.

@alecgibson alecgibson merged commit 21750e3 into master May 2, 2023
@alecgibson alecgibson deleted the reconnecting-socket-docs branch May 2, 2023 16:23
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

Successfully merging this pull request may close these issues.

3 participants