rust-lang / rust-lang/rust-analyzer
Shutdown request fails with "invalid type: map, expected unit" when params is empty object
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
The rust-analyzer language server rejects LSP shutdown requests when the params field contains an empty JSON object {}, causing the server to crash instead of shutting down gracefully. Emacs eglot recently changed to send {} instead of null to accommodate other language servers (like ocamllsp) that have strict validation requirements. This appears to be an issue with the lsp-server or lsp-types crates used by rust-analyzer. The deserialization logic expects unit (no params or null) but rejects an empty object {}, which is technically valid per the JSON-RPC spec.
Steps to Reproduce
- Start rust-analyzer via
M-x eglot - Send a shutdown request with
M-x eglot-shutdown - Server crashes with the following error
[eglot] Asking EGLOT (downloads/(rust-ts-mode rust-mode)) politely to terminate
[jsonrpc] (warning) Sentinel for EGLOT (downloads/(rust-ts-mode rust-mode)) still hasn't run, deleting it!
[jsonrpc] Server exited with status 9
jsonrpc-request: jsonrpc-error: "request id=6 failed:", (jsonrpc-error-code . -32602),
(jsonrpc-error-message . "Failed to deserialize shutdown: invalid type: map, expected unit; {}")
Expected Behavior
According to the JSON-RPC 2.0 specification, section 4.2:
If present, parameters for the rpc call MUST be provided as a Structured value. Either by-position through an Array or by-name through an Object.
An empty object {} is a valid structured value and should be accepted. The LSP specification inherits this from JSON-RPC.
Related Issues
- Emacs bug report: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=66144
- Similar issue reported for ty language server: https://github.com/astral-sh/ty/issues/1330
- Helix editor issue with ocamllsp: https://github.com/helix-editor/helix/issues/5400
rust-analyzer version: rust-analyzer 2025-08-25
rustc version: rustc 1.89.0 (29483883e 2025-08-04)
editor or extension: GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.49, cairo version 1.18.4)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the shutdown-parameter deserialization logic in the lsp-server or lsp-types crates, starting from the error reported for the shutdown request. Reproduce the request with an empty params object through Emacs eglot, then verify that rust-analyzer accepts {} and shuts down gracefully without the deserialization error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100