Skip to content

Commit

Permalink
fix(sync): preserve queue if sendRemainingSteps fails
Browse files Browse the repository at this point in the history
During a network disconnect
Yjs-websocket notices missing awareness messages and closes the connection.
In this case the remaining steps can also not be send out and the request fails.
Preserve the queue so we can use it once the network is back up.

Signed-off-by: Max <max@nextcloud.com>
  • Loading branch information
max-nextcloud committed Dec 11, 2023
1 parent e350433 commit 045391f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/services/WebSocketPolyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ export default function initWebSocketPolyfill(syncService, fileId, initialSessio

#sendRemainingSteps() {
if (this.#queue.length) {
let outbox = []
return syncService.sendStepsNow(() => {
outbox = [...this.#queue]
const data = {
steps: this.#steps,
awareness: this.#awareness,
Expand All @@ -136,6 +138,7 @@ export default function initWebSocketPolyfill(syncService, fileId, initialSessio
return data
})?.catch(err => {
logger.error(err)
this.#queue = [...outbox, ...this.#queue]
})
}
}
Expand Down

0 comments on commit 045391f

Please sign in to comment.