Skip to content

Catch content modified error #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

userNotFoundByDefault
Copy link
Contributor

Hi,

I was having a look into the "Content-Modified" error, that I got, when doing the other pull request (#161). The error also appeared when not using those code changes.
The LSP-Spec says, that the Content-Modified-Error appears, when the server is executing a request and the editor state changes, which in my understanding happens, when typing quite fast and the server is not keeping pace with the request executions (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#implementationConsiderations):

if a server detects an internal state change (for example, a project context changed) that invalidates the result of a request in execution the server can error these requests with ContentModified. If clients receive a ContentModified error, it generally should not show it in the UI for the end-user.

So I tracked down the position where the error is thrown, which is inside the service-manager, which is awaiting the Promise that is returned by the service-feature (in that case the language-client). That promise is rejected in case of the Content-Modified-Error, so the 'await' expression is throwing the error.
For every message-type, that is awaiting a promise I simply put a try-catch around the code, that is catching the error, which is ignored, if it is the "Content-Modified" error.

… waiting for the service-feature-promise to resolve (inside the service-manager), by wrapping the 'await' expressions into a try-catch-block. 'Content-Modifed' errors happen, when the result of a request in execution invalidates, because the internal state changes occured in the mean time. According to the LSP-Spec, these errors can be ignored and shall not be shown in the UI.
@mkslanc
Copy link
Owner

mkslanc commented Mar 14, 2025

I would like to handle this in other way. If there is a chance to solve this in client, by re-sending request or throttling it, we should take it. Especially in cases when delta changes caused that one. In other case client and server documents would be incrementally out-of-sync, which is not nice.

@userNotFoundByDefault
Copy link
Contributor Author

That seems to be a bigger change in the code base. Do you have an overview of where to install those changes as I am not yet that familiar with the code base.

@mkslanc
Copy link
Owner

mkslanc commented Mar 19, 2025

That seems to be a bigger change in the code base. Do you have an overview of where to install those changes as I am not yet that familiar with the code base.

It would be indeed big change, I think I'll tackle it myself.

@userNotFoundByDefault
Copy link
Contributor Author

Just a quick note: I will be offline for the next 2-3 months due to private reasons. Just so you are not wondering when I am not responding.

@mkslanc
Copy link
Owner

mkslanc commented Mar 27, 2025

Just a quick note: I will be offline for the next 2-3 months due to private reasons. Just so you are not wondering when I am not responding.
While you still here, which setup have you used to get this error? I tried luals in sockets mode, but have no luck

@userNotFoundByDefault
Copy link
Contributor Author

My colleague set it up. He sent me the console command:
./lsp-ws-proxy --listen 8080 -- ~/work/lua-language-server/lua-language-server/bin/lua-language-server --loglevel=trace --logpath=/tmp/ --stdio
For the Websocket a proxy was being used:
lsp-ws-proxy v0.9.0-rc.4

The version of the lua server is from 24. January 2025 (commitID: 06943cfabb3c8957a15c28ffc0ac7fbc18dfd8f7)

I think that the load of the server might be a thing. If the server does not immediately answer the requests due to load, the requests will be outdated. To enforce that, I am typing very fast. Even without autocomplete it needs to update the annotations (for example, if one line is already annotated as error, it needs to update it for every character typed).

Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants