redhat-developer / lsp4ij

LSP Client for IntelliJ
Eclipse Public License 2.0
85 stars 16 forks source link

org.eclipse.lsp4j.jsonrpc.ResponseErrorException: content modified #474

Open harry-xm opened 2 weeks ago

harry-xm commented 2 weeks ago

Happens when I quit and reopen the IDE with a .rs file open. I did not modify any files before the error popped up.

Error while consuming 'textDocument/codeAction' with language server 'Rust Language Server'

org.eclipse.lsp4j.jsonrpc.ResponseErrorException: content modified
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
    at com.redhat.devtools.lsp4ij.LanguageServerWrapper.lambda$start$1(LanguageServerWrapper.java:260)
    at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
    at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)

This also happens on textDocument/codeLens and textDocument/documentHighlight.

IDE information

PyCharm 2024.2.0.1 (Community Edition)
Build #PC-242.20224.428, built on August 21, 2024
Runtime version: 21.0.3+13-b509.4 aarch64 (JCEF 122.1.9)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 14.6.1
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 4096M
Cores: 8
Metal Rendering is ON
Registry:
  ide.experimental.ui=true
Non-Bundled Plugins:
  com.redhat.devtools.lsp4ij (0.4.0)
rust-analyzer 1.80.1 (3f5fd8dd 2024-08-06)
harry-xm commented 2 weeks ago

This could be a rust-analyzer bug, but is reported here for LSP4IJ to consider special handling for ContentModified errors.

angelozerr commented 2 weeks ago

If I understand correctly your issue the exception kind org.eclipse.lsp4j.jsonrpc.ResponseErrorException should be reported as language server and not as LSP4IJ https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#feedback , right?

harry-xm commented 2 weeks ago

I think the error is already reported as a language server error (i.e. the second case).

The concern is whether LSP4IJ should provide the facility to silence this error and automatically retry or cancel the request.

From the LSP spec:

/**
 * The server detected that the content of a document got
 * modified outside normal conditions. A server should
 * NOT send this error code if it detects a content change
 * in it unprocessed messages. The result even computed
 * on an older state might still be useful for the client.
 *
 * If a client decides that a result is not of any use anymore
 * the client should cancel the request.
 */
export const ContentModified: integer = -32801;