Skip to content

Commit 7d5fcf8

Browse files
committed
lsp: Delay server ready until after features are initialized
Related to the previous commit, the server was declaring itself ready before all the `initialized` handlers of the features were processed. This commit therefore attempts to be more correct by delaying the resolution of the `ready` future until after the execution of these handlers. However, the previous commit also demonstrates how this already insufficient to ensure correct behaviour as other requests/notifications are free to be serviced concurrently with `initialized`. The "obvious" fix for this would be to move all setup code into the `initialize` handler, but there is at least one situation where this cannot be done and that is the configuration system. Initializing the configuration system involves making `workspace/configuration` requests to the client - which are forbidden until after the `initialize` result has been sent! As I write this, perhaps the other "obvious" solution is to have all of the message handlers in `esbonio/server/setup.py` consult the state of the `ready` future before proceeding... but for some reason (I can't quite articulate why) that doesn't feel like an ideal solution...
1 parent 1a7a057 commit 7d5fcf8

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

lib/esbonio/esbonio/server/server.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ async def initialized(self, params: types.InitializedParams):
152152
self._register_did_change_configuration_handler(),
153153
self._register_did_change_watched_files_handler(),
154154
)
155-
self._ready.set_result(True)
156155

157156
def lsp_shutdown(self, params: None):
158157
"""Called when the server is instructed to ``shutdown`` by the client."""

lib/esbonio/esbonio/server/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ async def on_initialized(
7070
):
7171
await ls.initialized(params)
7272
await call_features(ls, "initialized", params)
73+
ls.ready.set_result(True)
7374

7475
@server.feature(types.SHUTDOWN)
7576
async def on_shutdown(ls: EsbonioLanguageServer, params: None):

0 commit comments

Comments
 (0)