Skip to content

Commit 2da37d4

Browse files
committed
fix: return MethodNotFound error for unrecognized LSP requests
When receiving an unsupported LSP method, the server now returns a proper MethodNotFound (-32601) error response instead of silently dropping the request. This prevents well-behaved clients from hanging indefinitely waiting for a response.
1 parent 463836c commit 2da37d4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/ruby_lsp/server.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ def process_message(message)
120120
@global_state.synchronize { @cancelled_requests << message[:params][:id] }
121121
when nil
122122
process_response(message) if message[:result]
123+
else
124+
if message[:id]
125+
send_message(Error.new(
126+
id: message[:id],
127+
code: Constant::ErrorCodes::METHOD_NOT_FOUND,
128+
message: "Method not found: #{message[:method]}",
129+
))
130+
end
123131
end
124132
rescue DelegateRequestError
125133
send_message(Error.new(id: message[:id], code: DelegateRequestError::CODE, message: "DELEGATE_REQUEST"))

0 commit comments

Comments
 (0)