leanprover / leanprover/lean4

Lean server does not accept `exit` notification before `initialize`

Open
#1,216 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement low priority P-low server
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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.