Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(sync): Apply document state from create request
Prevents possible race condition when steps from first sync request got
applied before documentState from first push request (answer to
SyncStep1) arrived.

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- authored and max-nextcloud committed Oct 13, 2025
commit d9fe6ebbb64be7eb7f86f95228b2133a6226404f
6 changes: 4 additions & 2 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ import {
import ReadonlyBar from './Menu/ReadonlyBar.vue'

import { logger } from '../helpers/logger.js'
import { getDocumentState } from '../helpers/yjs.ts'
import { applyDocumentState, getDocumentState } from '../helpers/yjs.ts'
import { SyncService, ERROR_TYPE, IDLE_TIMEOUT } from './../services/SyncService.ts'
import SessionApi from '../services/SessionApi.js'
import createSyncServiceProvider from './../services/SyncServiceProvider.js'
Expand Down Expand Up @@ -556,7 +556,9 @@ export default {
},

onLoaded({ document, documentSource, documentState }) {
if (!documentState) {
if (documentState) {
applyDocumentState(this.$ydoc, documentState, this.$providers[0])
} else {
this.setInitialYjsState(documentSource, { isRichEditor: this.isRichEditor })
}

Expand Down
5 changes: 0 additions & 5 deletions src/services/y-websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,6 @@ const setupWS = (provider) => {
provider.emit('status', [{
status: 'connected',
}])
// always send sync step 1 when connected
const encoder = encoding.createEncoder()
encoding.writeVarUint(encoder, messageSync)
syncProtocol.writeSyncStep1(encoder, provider.doc)
websocket.send(encoding.toUint8Array(encoder))
// broadcast local awareness state
if (provider.awareness.getLocalState() !== null) {
const encoderAwarenessState = encoding.createEncoder()
Expand Down
Loading