You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sync fails if initial state is present in the yjs document #4480
Describe the bug
If there is some initial state in the yjs document our sync mechanism fails and changes from the user in question are not transferred.
If a yjs session starts with initial data in the document the client will not send updates for that initial data. Normally this is not a problem because the initial Sync message 1 by the other party will cause the client to send it's 'backlog'.
It's not clear if this can happen in a real life scenario. Tiptap may take longer to load than yjs takes to initialize and send the initial push message.
To Reproduce
Add this test to cypress/e2e/api/SyncServiceProvider.spec.js:
it('syncs even when initial state was present',function(){constsourceMap=this.source.getMap()consttargetMap=this.target.getMap()sourceMap.set('unrelated','value')cy.intercept({method: 'POST',url: '**/apps/text/session/push'}).as('push')cy.intercept({method: 'POST',url: '**/apps/text/session/sync'}).as('sync')cy.wait('@push')cy.then(()=>{sourceMap.set('keyA','valueA')expect(targetMap.get('keyB')).to.be.eq(undefined)})cy.wait('@sync')cy.wait('@sync')// eslint-disable-next-line cypress/no-unnecessary-waitingcy.wait(1000)cy.then(()=>{expect(targetMap.get('keyA')).to.be.eq('valueA')})})
Uh... interesting. Had forgotten about this one. It's probably still failing as my fix only applies after some document state has been saved. But it could (and probably should) be expended to also address this one. Nice to know there's already a test for this. It should still work. Will add it to my todo list.
Activity
juliusknorr commentedon Jan 25, 2024
@max-nextcloud Sounds a bit like your recent fix addressed this, but not sure if the test case is still applicable?
max-nextcloud commentedon Jan 25, 2024
Uh... interesting. Had forgotten about this one. It's probably still failing as my fix only applies after some document state has been saved. But it could (and probably should) be expended to also address this one. Nice to know there's already a test for this. It should still work. Will add it to my todo list.
mejo- commentedon Mar 20, 2024
@max-nextcloud should we close this for now, given that we did quite a bit of refactoring of create/sync/push? Or would you like to keep it open?
max-nextcloud commentedon Oct 7, 2025
6613cf6 fixed this. I'm working on adding the test to the test suite and make it run more reliable. Afterwards I'll close this.
chore(test): add test for 4480
mejo- commentedon Oct 15, 2025
Pr #4480 will add the missing test.
chore(test): add test for 4480
chore(test): add test for 4480
chore(test): add test for 4480