Component
pygls/protocol/json_rpc.py
Summary
After receiving the shutdown request, _shutdown is set to True and handle_message rejects every subsequent message except exit. This includes responses from the client to requests that the server sent before shutdown (e.g., client/registerCapability, workspace/configuration). Per the LSP specification, the server must not exit until exit is received, and in-flight bidirectional communication must still be honored.
Steps to Reproduce
- Server sends a request to the client (e.g.,
workspace/configuration).
- Client sends
shutdown before responding.
- The server drops the client's response because
_shutdown blocks it.
- The internal
Future associated with the request leaks and never resolves.
Expected Behavior
_handle_response should continue processing even after shutdown. Only new client requests/notifications (other than exit) should be ignored.
Actual Behavior
All messages except exit are dropped after shutdown.
Affected Code (pygls/protocol/json_rpc.py, ~L496-498)
if self._shutdown and getattr(message, "method", "") != EXIT:
logger.warning("Server shutting down. No more requests!")
return
Proposed Fix
Guard _handle_request and _handle_notification, but allow _handle_response to pass through regardless of the _shutdown flag.
Component
pygls/protocol/json_rpc.py
Summary
After receiving the
shutdownrequest,_shutdownis set toTrueandhandle_messagerejects every subsequent message exceptexit. This includes responses from the client to requests that the server sent before shutdown (e.g.,client/registerCapability,workspace/configuration). Per the LSP specification, the server must not exit untilexitis received, and in-flight bidirectional communication must still be honored.Steps to Reproduce
workspace/configuration).shutdownbefore responding._shutdownblocks it.Futureassociated with the request leaks and never resolves.Expected Behavior
_handle_responseshould continue processing even after shutdown. Only new client requests/notifications (other thanexit) should be ignored.Actual Behavior
All messages except
exitare dropped after shutdown.Affected Code (
pygls/protocol/json_rpc.py, ~L496-498)Proposed Fix
Guard
_handle_requestand_handle_notification, but allow_handle_responseto pass through regardless of the_shutdownflag.