Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[lsp4e-dev] LSP4e document corruption
  • From: Thomas Gibson-Robinson <tom@xxxxxxxxxx>
  • Date: Thu, 17 Mar 2022 11:20:42 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cocotec.io; dmarc=pass action=none header.from=cocotec.io; dkim=pass header.d=cocotec.io; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U6jMGTDXtGsCtlPbXDZQBgxhtkclWTM4rVGhSInNqFI=; b=hBPyaK2AmL0BxaeabTprAxEFdFieblwjr91pGFtJDXBCAZoeHOKKmn571ZRz44zPH3myXzSRidq/Kmf9Gi0awv6eqn74sVkTl4FKFVeukjoQ9zfUnx4XIZqvX0g/wuxhMPKCA/7WWXAHm+NUcDnhQ6uLSh4h7pR1OL84VF1+9BUDaDt8w7hIh5VhtJLucwuTbYVJMjLg1UrdbMU8cLICbst8Qv0mW3pVu9VAyPRDckk1hBcSAb3XetUswd83yaabazVT8SNBwloA3hpLUyELjCNGLScEGa4EBjuc0muob9vHIroAMx9XfgAwxJiQP9by+e5trtT/LA4c2YIAKTKIbg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M9/XJZx42+ihlXDIa1ddt0odLcuP59GfQNTHdIl/7xftYW0/j05HvV4z4oYBod9dDviofV4ncpX+20xOw+elatb96uNetwDYE4AFt5FDNml1bfkRG0UjNpsaQ+QHC2QbKU8FhfzYlbVE0soND735firJlFhf6m0ktHrhdc3B8xtO/pBrPDAR6hAPM4X6JpEV/dgF/Ynr/pv5aekN1h/Jxa6IebhVwRmuLKBu1BAwy3u6O5R7ydJ5etayIFXORq6yoo17MenmhP0F4fcBURij2q8kWV5gWrWbL9XW0xjCxURJPj5SiDFgGzyS//jvRYlJx63G/xQ9KOfANLaZn4nUwA==
  • Delivered-to: lsp4e-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/lsp4e-dev/>
  • List-help: <mailto:lsp4e-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/lsp4e-dev>, <mailto:lsp4e-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/lsp4e-dev>, <mailto:lsp4e-dev-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AQHYOfEJjzoSfYGYRkOT0S8KxGpL3Q==
  • Thread-topic: LSP4e document corruption

Hi all,

One thing that we’ve noticed when using LSP4e is that the server’s view on documents appears to very occasionally get out of sync with a client’s. This can manifest itself either by Eclipse showing problems for old versions of the file, or showing seemingly random error messages that indicate the server has a completely different view of the editor’s content. This seems to be more common when the system is under high load.


languageServerWrapper.getInitializedServer()
.thenAcceptAsync(ls -> ls.getTextDocumentService().didChange(changeParamsToSend));

My understanding of Java futures is that unless a special executor is used, there is no guarantee about the order in which futures are executed, even when the futures are created by a single thread. Therefore, the body of the above lambda (i.e. the didChange call) could, in theory, be executed out-of-order with respect to other calls to the language server, including other didChange notifications. This could lead to the server applying the modifications in the wrong order, leading to the server’s version of the document becoming corrupted (in the case of didChange sending diffs), or to be the wrong version (in the case of didChange sending full file contents each time).

I’ve also noticed that there are some other places in the codebase that seemingly suffer from similar issues: for example didSave and didChange need to appear in the right order but currently this is nothing to enforce this. Also, a request to format the current document should happen only after the corresponding didChange notifications, and before other didChange notifications.

Does this seem like a genuine problem with LSP4e, or am I missing something about Java futures that means the FIFO order is otherwise guaranteed? If this does seem like a genuine problem, would a patch that enforces FIFO ordering on some requests be welcome? This would probably mean sequentialising didChange, didSave and formatting-related requests, although I do wonder if (almost?) all requests should be included in some linear ordering, given that the editor probably wants (e.g.) code lenses or code completion for the current document version, not the version that will be created in the future after the user types some extra content.

Thanks,

Tom


Back to the top