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.
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 ononConnect
andonSync
. 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
createDocument
this.documents.set(documentName, document)
immediately happensonLoadDocument
async hookthis.documents.has(documentName)
is true and receives an empty doc, and successfully connects to an empty doconLoadDocument
hook resolvesExpected behavior
onLoadDocument
async hookonLoadDocument
is still in progressonLoadDocument
hook resolves