Skip to content
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

Use separate thread to handle didChangeWatchedFiles events #2643

Merged

Conversation

testforstephen
Copy link
Contributor

See #2518 (comment), executing the file event handler in the default dispatch thread may block the jsonrpc reader. To avoid the deadlock, use a separate thread to handle didChangeWatchedFiles events.

Copy link
Contributor

@snjeza snjeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jdneo
Copy link
Contributor

jdneo commented May 10, 2023

Looks like we are now using a consumer thread handling the event and make it 'non-blocking'.

Compare to the previous blocking strategy, will this change impact on the result of the following arriving LSP request?

@testforstephen
Copy link
Contributor Author

Looks like we are now using a consumer thread handling the event and make it 'non-blocking'.

Compare to the previous blocking strategy, will this change impact on the result of the following arriving LSP request?

The main task in didChangeWatchedFiles is to sync the resource tree with the local file system and update the project configuration if a build file is updated. The project update is already in a separate workspace job, so it is not affected by this PR. The remaining question is the impact of delaying the resource tree refresh.

I will assess its impact case by case. The didChangeWatchedFiles events can come from two typical use cases. The first use case is when you edit and save a file in VS Code. In this case, the Java model has been updated in the document lifecycle handler and its contents are visible to other actions. So delaying the response to the didChangeWatchedFiles event should not be a problem.

The second use case is when the file events are from external operations, such as git checkout branch. This does not affect the document lifecycle operations like didOpen/didChange, because the client will always send the latest contents to the server in these document notifications. For other operations like code completion, you may get some outdated proposals if the related resource is not refreshed yet. The question we need to consider is the balance between responsiveness and reliability. For me, it is better to respond with something than nothing.

@testforstephen testforstephen merged commit e5a9069 into eclipse-jdtls:master May 17, 2023
6 checks passed
@testforstephen testforstephen added this to the End May 2023 milestone May 17, 2023
@testforstephen testforstephen deleted the jinbo_eventhandler branch May 17, 2023 02:04
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.

None yet

3 participants