diff --git a/src/services/SyncService.ts b/src/services/SyncService.ts index 5a6f7c06e51..c16e8a0f0c3 100644 --- a/src/services/SyncService.ts +++ b/src/services/SyncService.ts @@ -236,6 +236,7 @@ class SyncService { this.bus.emit('stateChange', { dirty: true }) } if (!this.hasActiveConnection()) { + this.#sending = false return } const sendable = this.#outbox.getDataToSend() diff --git a/src/tests/services/SyncService.spec.ts b/src/tests/services/SyncService.spec.ts index 2707f1fd0f5..035dd57f5aa 100644 --- a/src/tests/services/SyncService.spec.ts +++ b/src/tests/services/SyncService.spec.ts @@ -42,6 +42,17 @@ const initialData = { const openResult = { connection, data: initialData } describe('Sync service', () => { + it('resets #sending when there is no active connection', async () => { + const { connection, openConnection } = provideConnection( + { fileId: 123, relativePath: './' }, + vi.fn(), + vi.fn(), + ) + const service = new SyncService({ connection, openConnection }) + await service.sendStepsNow() + await expect(service.sendStepsNow()).resolves.toBeUndefined() + }) + it('opens a connection', async () => { const getBaseVersionEtag = vi.fn() const setBaseVersionEtag = vi.fn()