rust-lang / rust-lang/rust-analyzer

Shutdown request fails with "invalid type: map, expected unit" when params is empty object

Open
#20,846 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
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
  1. Start rust-analyzer via M-x eglot
  2. Send a shutdown request with M-x eglot-shutdown
  3. 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

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.