- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 313
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Sync is called with isSynced true, but my document item is empty. This behavior is intermittent.
I need to add a delay before accessing the document.
Here is a helper function that includes a delay that resolves the problem. Without the delay, my doc.getText().length is sometimes '0', even though a document exists in the backend.
My test show the bigger the document, the more delay i need to add.
For reference, my backend is the published server example using a leveldb store.
await waitForSync()
console.log(doc.getText().length)async function waitForSync() {
    return new Promise((resolve, reject) => {
      if (wsProvider.synced) {
        setTimeout(() => {
          return resolve(undefined)
        }, 200)
      }
      wsProvider.once('sync', () => {
        setTimeout(() => {
          resolve(undefined)
        }, 200)
      })
    });
  }Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working