-
Notifications
You must be signed in to change notification settings - Fork 51
fix: don't drop inbound workspace/didChangeConfiguration notifications
#856
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
Conversation
Summary of ChangesHello @Davidyz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a significant initialization order bug within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly fixes a race condition during initialization by ensuring init_analysis is called after the workspace_manager is fully initialized. The logic is sound and resolves the described issue. I've added one comment regarding a redundant calculation of file patterns that could be refactored for better efficiency and code clarity. Otherwise, the change is good.
|
This is not the correct way to fix the issue. This approach is essentially a race between different requests reaching the language server. It's entirely possible for workspace/configuration to reach the language server first, and then for workspace_manager to finish initialization afterwards. |
|
Actually, I know how to fix it, see here, remove the "workspace/didChangeConfiguration"
but I think initializing twice is really stupid. |
|
I think the place that should be fixed is here: I have already proactively requested the configuration from the client, so why hasn't it taken effect? |
Thanks for the comments, but I'm not totally convinced. In
I agree that we should avoid initialize (that is, the
This might have been a timing issue. In lazydev.nvim (a neovim plugin that dynamically updates |
This might be a translation issue. When I mentioned "race," I didn't mean a race condition, but rather that the handling order of these two requests could be random. So it's still possible that when processing workspace/configuration, the workspace_manager's initialized flag hasn't been set yet. The reason why swapping the order currently works is because init_analysis takes quite some time to process. I can accept initializing twice on lazyvim, but I can't accept this change affecting other platforms, because in the game environment there could be tens of thousands of Lua files, and the cost of initializing twice is too high. |
I take it that when you say "initializing twice", you're referring to the
Since |
|
This is the correct method but not the appropriate one. This issue is introduced by lazyvim and is not a problem with all editors. If every editor correctly sent workspace/configuration, I could simply wait for its result before starting initialization. However, that's not the case—some editors may not support workspace/configuration. I can't rely on this behavior for my initialization. Now there is another method: adding a dedicated |
I think that's unfair. This issue is caused by the workspace manager not fully initialized after the server sends the
May I propose another approach: In Update: tbh this alternative approach is still not perfect because there can still be incoming |
|
I realized it's actually not that complicated, because in practice, other editors don't actively send workspace/configuration requests. The current check for initialized in workspace/configuration is an outdated solution, since I have modified the main_loop implementation to allow pending requests. Therefore, the initialized field in workspace_manager can be removed and allow pending the |
|
@CppCXY I've removed the |
|
I think you can remove |
workspace/didChangeConfiguration notifications
|
There might still be something wrong with this PR. Now I sometimes don't get the updated workspace library at all (even after opening the second file). From the logs it seems like the server was able to pull the client configs. |
|
@CppCXY I'm noticing deadlocks in |
|
I was just poking around the notification handlers that are triggered at the beginning of a session, and flipping the order of |
|
can you make a pr fix this? |
|
I'm still trying to figure out the underlying mechanism of the deadlock. I encountered some (very rare) deadlocks even with the previously mentioned "fix", so it's probably not the actual culprit. I don't want to submit another non-solution. btw if you want to revert this PR due to the deadlock, I'm ok with it. |
I think we can simply restore the use of the initialized field, because it was originally designed to solve deadlocks. |
I think that'll bring back the "discarding notification" issue because |
|
I try fix this deadlock: b3d565e |
|
@CppCXY seems to work fine. Thanks. btw, the following is what I've come up with about the deadlock issue:
Since async notification handlers are spawned to run concurrently, they can run in parallel with the message loop in I think finer control over the progress bar might help solve this issue. The current implementation also doesn't care whether the client supports progress bar capabilities. If it doesn't (or if the user decided to disable it), and therefore doesn't send a reply to the |
In #765 there were discussions about the first file opened in neovim won't have the updated config (
workspace.libraryfor dynamically adding libraries) sent in theworkspace/configurationresponse.I believe this was caused by the
init_analysisfunction being called before the workspace manager has been initialized. This means the workspace manager in theworkspace/configurationhandler is incorrectly marked as uninitialized for the first file.This PR address the issue, and when used in neovim and lazydev.nvim,
emmylua_lscan now correctly load the dynamically added libraries.