From 0f4dadb1c61030b2e1c96f29fcf4e9a5ad8c3228 Mon Sep 17 00:00:00 2001 From: Roberto Date: Tue, 18 Aug 2026 20:59:58 +0200 Subject: [PATCH] fix(vfs): do not send an empty applyOtUpdate on save When a document is saved without any real change, the computed diff has an empty `op` array. The update is still sent, and the real-time service answers with an error object and force-disconnects the client shortly after, so the user sees `Unable to write file ... ([object Object])` followed by a reconnection loop. `isDirty` already records whether the update carries any operation: use it to skip the round-trip entirely. The local/remote caches are updated as before. --- src/core/remoteFileSystemProvider.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/remoteFileSystemProvider.ts b/src/core/remoteFileSystemProvider.ts index 0746f73..96a44ee 100644 --- a/src/core/remoteFileSystemProvider.ts +++ b/src/core/remoteFileSystemProvider.ts @@ -879,7 +879,12 @@ export class VirtualFileSystem extends vscode.Disposable { })(), }; this.isDirty = (update.op && update.op.length) ? true : false; - await this.socket.applyOtUpdate(doc._id, update); + // Skip the round-trip when the diff produced no operation (e.g. saving an + // unchanged document): the server has nothing to apply, answers with an error + // object and then force-disconnects the client 100ms later. + if (this.isDirty) { + await this.socket.applyOtUpdate(doc._id, update); + } doc.localCache = mergeRes; doc.remoteCache = mergeRes; setTimeout(() => {