diff --git a/src/components/Editor.vue b/src/components/Editor.vue index 9d256b9b194..18c3fc3192b 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -703,7 +703,9 @@ export default { async close() { await this.$syncService.sendRemainingSteps() + .catch(err => logger.warn('Failed to send remaining steps', { err })) await this.disconnect() + .catch(err => logger.warn('Failed to disconnect', { err })) if (this.$editor) { try { this.unlistenEditorEvents() diff --git a/src/services/Outbox.ts b/src/services/Outbox.ts index 6c27a04872f..2ca82416b8d 100644 --- a/src/services/Outbox.ts +++ b/src/services/Outbox.ts @@ -17,7 +17,7 @@ export default class Outbox { storeStep(step: Uint8Array) { const encoded = encodeArrayBuffer(step) - if (encoded < 'AAA') { + if (encoded < 'AAA' || encoded > 'Ag') { logger.warn('Unexpected step type:', { step, encoded }) return } @@ -29,11 +29,7 @@ export default class Outbox { this.#syncUpdate = encoded return } - if (encoded < 'Ag') { - this.#awarenessUpdate = encoded - return - } - logger.warn('Unexpected step type:', { step, encoded }) + this.#awarenessUpdate = encoded } getDataToSend(): Sendable { @@ -48,7 +44,7 @@ export default class Outbox { } /* - * Clear data that has just been + * Clear data that has just been sent. * * Only clear data that has not changed in the meantime. * @param {Sendable} - data that was to the server diff --git a/src/services/SyncService.js b/src/services/SyncService.js index 669731503d7..fc2f035a5b1 100644 --- a/src/services/SyncService.js +++ b/src/services/SyncService.js @@ -307,8 +307,8 @@ class SyncService { } sendRemainingSteps() { - if (!this.outbox.hasUpdate()) { - return + if (!this.#outbox.hasUpdate) { + return Promise.resolve() } logger.debug('sending final steps') return this.sendStepsNow().catch(err => logger.error(err))