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

Connections to doc are possible while onLoadDocument is still in progress #821

Closed
jordangarcia opened this issue May 10, 2024 · 0 comments · Fixed by #822
Closed

Connections to doc are possible while onLoadDocument is still in progress #821

jordangarcia opened this issue May 10, 2024 · 0 comments · Fixed by #822
Assignees
Labels
bug Something isn't working

Comments

@jordangarcia
Copy link
Contributor

jordangarcia commented May 10, 2024

Description
The issue arises when multiple client connections come in for the same document, the first connection will kick off and await the onLoadDocument hook, however subsequent connections (while its still loading) incorrectly receive a connection to an empty document. When paired with @hocuspocus/provider it changes the meaning on onConnect and onSync. For the first client both of those hooks imply that the document has been loaded. For the second connection it is ambiguous if the document has been loaded.

Steps to reproduce the bug

  • client1 connects to doc
  • client1 connection invokes createDocument
  • this.documents.set(documentName, document) immediately happens
  • client1 starts onLoadDocument async hook
  • client2 connects, sees that this.documents.has(documentName) is true and receives an empty doc, and successfully connects to an empty doc
  • client1 onLoadDocument hook resolves
  • client1 successfully connects

Expected behavior

  • client1 connects to doc
  • client1 connection invokes createDocument
  • client1 starts onLoadDocument async hook
  • client2 connects, sees that onLoadDocument is still in progress
  • client1 onLoadDocument hook resolves
  • client1 successfully connects
  • client2 successfully connects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants