Lean server does not accept `exit` notification before `initialize`
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Checked that your issue isn't already filed.
- Reduced the issue to a self-contained, reproducible test case.
Description
The server does not properly accept exit notifications before an initialize. This violates the LSP specification (see here). The server also does not properly respond to an invalid initial request (the specification requires a response with code: -32002 whereas the sever just exits with error code 1).
Steps to Reproduce
As notification:
echo -n $'Content-Length: 45\r\n\r\n{"jsonrpc":"2.0","method":"exit","params":[]}' | lean --server
As request:
echo -n $'Content-Length: 52\r\n\r\n{"jsonrpc":"2.0","method":"exit","params":[],"id":1}' | lean --server
Expected behavior:
The server to exit gracefully with code 0 upon receiving an initial exit notification.
Actual behavior:
As notification:
Watchdog error: Cannot read LSP request: Expected JSON-RPC request, got: '{"params":[],"method":"exit","jsonrpc":"2.0"}'
As request:
Watchdog error: Cannot read LSP request: Expected method 'initialize', got method 'exit'
Reproduces how often:
Always.
Versions
Windows 10 20H2
Lean (version 4.0.0-nightly-2022-06-14, commit 77ae79be466c, Release)
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
Start by running the two provided lean --server reproductions and compare their behavior with the linked LSP initialize specification. Trace the server's pre-initialize request handling; done means an initial exit notification exits with code 0 and an initial exit request receives the specified -32002 response.
Written by the indexing model from the issue text.
Assessment
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100