jeapostrophe / racket-langserver

Other
262 stars 24 forks source link

Server initialization failed: The JSON sent is not a valid request object. (racket/racket#4532) #94

Closed shhyou closed 1 year ago

shhyou commented 1 year ago

A recent bug fix racket/racket#4532 going into Racket 8.8 changes the semantics of hash table patterns, so it breaks racket-langserver with the following error messages:

A request has failed. See the output for more information.

Server initialization failed.
  Message: The JSON sent is not a valid request object.
  Code: -32600 

Starting client failed
  Message: The JSON sent is not a valid request object.
  Code: -32600 

This piece of code now expects to match the full hash table instead of matching only the mentioned key-value pair:

;; Before: check the `id` field and the `method` field
;; After: asserts that `msg` only has the `id` field and the `match` field
(match msg
    ;; Request
    [(hash-table ['id (? (or/c number? string?) id)]
                 ['method (? string? method)])
     (define params (hash-ref msg 'params hasheq))
     (define response (process-request id method params))
     (display-message/flush response)]
    ...

I'm happy to send a PR but it'd take a while.

shhyou commented 1 year ago

Closing as racket/racket#4532 is reverted. sorawee's new PR racket/racket#4632 uses a different pattern name.