Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP log continualy gets scattered with haskell-lsp:incoming message parse error #1476

Closed
konn opened this issue Mar 2, 2021 · 4 comments · Fixed by haskell/lsp#295 or #1631
Closed
Labels
component: lsp type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@konn
Copy link
Collaborator

konn commented Mar 2, 2021

Summary

Though it seems unharmful, the current LSP log of HLS 1.0.0 gets scattered with sporadic error telling:

[Error - 11:36:31] haskell-lsp:incoming message parse error. {"jsonrpc":"2.0","id":3,"result":null} Error in $.result: parsing () failed, expected Array, but encountered Null

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

$ ~/Library/Application\ Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-1.0.0-darwin-8.10.4 --probe-tools
haskell-language-server version: 1.0.0.0 (GHC: 8.10.4) (PATH: /Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-1.0.0-darwin-8.10.4) (GIT hash: 4cd1cf934638881e52b3eba9f70157a4b799c0e9)
Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.5.1

Which lsp-client do you use: VSCode

Describe your project (alternative: link to the project): simple exe-only project which is generated by stack new foo simple, containing the following Main.hs as the only module:

module Main where

main :: IO ()
main = return ()

Contents of hie.yaml: No hie.yaml needed; it's just a simple project.

small-repro.cabal:

name:                small-repro
version:             0.1.0.0
-- synopsis:
-- description:
homepage:            https://github.com/githubuser/small-repro#readme
license:             BSD3
license-file:        LICENSE
author:              Author name here
maintainer:          example@example.com
copyright:           2021 Author name here
category:            Web
build-type:          Simple
cabal-version:       >=1.10
extra-source-files:  README.md

executable small-repro
  hs-source-dirs:      src
  main-is:             Main.hs
  default-language:    Haskell2010
  build-depends:       base >= 4.7 && < 5

Steps to reproduce

  1. Open Main.hs
  2. Open Haskell Output

Expected behaviour

No error nor warning.

Actual behaviour

Log containing several occurences the following error:

[Error - 11:41:21] haskell-lsp:incoming message parse error. {"jsonrpc":"2.0","id":3,"result":null} Error in $.result: parsing () failed, expected Array, but encountered Null

The attached log contains only a few errors, but when one runs HLS on a project with several modules and local deps, the number of error reported (and ignroed) becomes large.
Although there is no observable dysfunction related to this so far, it makes analysing LSP log relatively tedious.

Include debug information

Execute in the root of your project the command haskell-language-server --debug . and paste the logs here:

Debug output:
debug . 
haskell-language-server version: 1.0.0.0 (GHC: 8.10.4) (PATH: /Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-1.0.0-darwin-8.10.4) (GIT hash: 4cd1cf934638881e52b3eba9f70157a4b799c0e9)
ghcide setup tester in /Users/hiromi/Documents/Programming/Haskell/git/small-repro.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /Users/hiromi/Documents/Programming/Haskell/git/small-repro
Found 2 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  ()

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
2021-03-02 11:44:00.148551 [ThreadId 4] DEBUG hls:      Set files of interest to: [(NormalizedFilePath "/Users/hiromi/Documents/Programming/Haskell/git/small-repro/Setup.hs",OnDisk),(NormalizedFilePath "/Users/hiromi/Documents/Programming/Haskell/git/small-repro/src/Main.hs",OnDisk)]
2021-03-02 11:44:00.14946 [ThreadId 41] INFO hls:       File:     
Hidden:   no
Range:    1:1-2:1
Source:   compiler
Severity: DsError
Message: 
  Internal error, getIdeGlobalExtras, no entry for IdeConfigurationVar
  CallStack (from HasCallStack):
  errorIO, called at src/Development/IDE/Core/Shake.hs:284:20 in
  ghcide-1.0.0.0-inplace:Development.IDE.Core.Shake
2021-03-02 11:44:00.156761 [ThreadId 63] INFO hls:      Consulting the cradle for "Setup.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/hiromi/Documents/Programming/Haskell/git/small-repro", cradleOptsProg = CradleAction: Stack}
2021-03-02 11:44:00.162794 [ThreadId 63] DEBUG hls:     Session loading result: Left [CradleError {cradleErrorDependencies = [], cradleErrorExitCode = ExitSuccess, cradleErrorStderr = ["Multi Cradle: No prefixes matched","pwd: /Users/hiromi/Documents/Programming/Haskell/git/small-repro","filepath: /Users/hiromi/Documents/Programming/Haskell/git/small-repro/Setup.hs","prefixes:","(\"./src/Main.hs\",Stack {component = Just \"small-repro:exe:small-repro\", stackYaml = Nothing})"]}]
2021-03-02 11:44:00.163034 [ThreadId 59] INFO hls:      File:     /Users/hiromi/Documents/Programming/Haskell/git/small-repro/Setup.hs
Hidden:   no
Range:    1:1-2:1
Source:   cradle
Severity: DsError
Message: 
  Multi Cradle: No prefixes matched
  pwd: /Users/hiromi/Documents/Programming/Haskell/git/small-repro
  filepath: /Users/hiromi/Documents/Programming/Haskell/git/small-repro/Setup.hs
  prefixes:
  ("./src/Main.hs",Stack {component = Just "small-repro:exe:small-repro", stackYaml = Nothing})
2021-03-02 11:44:00.163916 [ThreadId 66] INFO hls:      Consulting the cradle for "src/Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/hiromi/Documents/Programming/Haskell/git/small-repro", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `small-repro' component small-repro:exe:small-repro with main-is file: /Users/hiromi/Documents/Programming/Haskell/git/small-repro/src/Main.hs
> Building all executables for `small-repro' once. After a successful build of all of them, only specified executables will be rebuilt.
> small-repro> configure (exe)
> Configuring small-repro-0.1.0.0...
> small-repro> initial-build-steps (exe)
> Configuring GHCi with the following packages: small-repro
> /Users/hiromi/Documents/Programming/Haskell/git/small-repro/.stack-work/install/x86_64-osx/558c152a1bb96869716c728ef95f5578695b79c7caaea744a13c987678024fb0/8.10.4/pkgdb:/Users/hiromi/.stack/snapshots/x86_64-osx/558c152a1bb96869716c728ef95f5578695b79c7caaea744a13c987678024fb0/8.10.4/pkgdb:/Users/hiromi/.stack/programs/x86_64-osx/ghc-8.10.4/lib/ghc-8.10.4/package.conf.d
2021-03-02 11:44:03.236375 [ThreadId 66] DEBUG hls:     Session loading result: Right (ComponentOptions {componentOptions = ["-i","-odir=/Users/hiromi/Documents/Programming/Haskell/git/small-repro/.stack-work/odir","-hidir=/Users/hiromi/Documents/Programming/Haskell/git/small-repro/.stack-work/odir","-hide-all-packages","-i/Users/hiromi/Documents/Programming/Haskell/git/small-repro/.stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build/small-repro","-i/Users/hiromi/Documents/Programming/Haskell/git/small-repro/src","-i/Users/hiromi/Documents/Programming/Haskell/git/small-repro/.stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build/small-repro/autogen","-i/Users/hiromi/Documents/Programming/Haskell/git/small-repro/.stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build/global-autogen","-i/Users/hiromi/Documents/Programming/Haskell/git/small-repro/.stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build/small-repro/small-repro-tmp","-stubdir=/Users/hiromi/Documents/Programming/Haskell/git/small-repro/.stack-work/dist/x86_64-osx/Cabal-3.2.1.0/build","-package-id=base-4.14.1.0","-optP-include","-optP/Users/hiromi/Documents/Programming/Haskell/git/small-repro/.stack-work/ghci/aab4ac53/cabal_macros.h","-ghci-script=/private/var/folders/pv/mtbzyjyj229g928n710c9d_40000gn/T/haskell-stack-ghci/3fc992d2/ghci-script","-package-db","/Users/hiromi/Documents/Programming/Haskell/git/small-repro/.stack-work/install/x86_64-osx/558c152a1bb96869716c728ef95f5578695b79c7caaea744a13c987678024fb0/8.10.4/pkgdb","-package-db","/Users/hiromi/.stack/snapshots/x86_64-osx/558c152a1bb96869716c728ef95f5578695b79c7caaea744a13c987678024fb0/8.10.4/pkgdb","-package-db","/Users/hiromi/.stack/programs/x86_64-osx/ghc-8.10.4/lib/ghc-8.10.4/package.conf.d"], componentRoot = "/Users/hiromi/Documents/Programming/Haskell/git/small-repro", componentDependencies = ["small-repro.cabal","package.yaml","stack.yaml"]},"/Users/hiromi/.stack/programs/x86_64-osx/ghc-8.10.4/lib/ghc-8.10.4")
2021-03-02 11:44:03.33229 [ThreadId 66] INFO hls:       Using interface files cache dir: /Users/hiromi/.cache/ghcide/main-a1f4958c591824e1a2927712572780e3b7d3153e
2021-03-02 11:44:03.332477 [ThreadId 66] INFO hls:      Making new HscEnv[main]
2021-03-02 11:44:03.337466 [ThreadId 66] DEBUG hls:     New Component Cache HscEnvEq: (([],Just HscEnvEq 24),fromList [("package.yaml",Nothing),("small-repro.cabal",Just 2021-02-15 12:05:43.565552288 UTC),("stack.yaml",Just 2021-02-15 12:05:44.538100624 UTC)])
2021-03-02 11:44:03.3378 [ThreadId 66] DEBUG hls:       Known files updated: fromList [(TargetFile NormalizedFilePath "/Users/hiromi/Documents/Programming/Haskell/git/small-repro/src/Main.hs",["/Users/hiromi/Documents/Programming/Haskell/git/small-repro/src/Main.hs"])]
2021-03-02 11:44:03.340945 [ThreadId 22] DEBUG hls:     Finishing build session(exception: AsyncCancelled)
2021-03-02 11:44:03.341078 [ThreadId 66] DEBUG hls:     Restarting build session (aborting the previous one took 0.00s)
2021-03-02 11:44:03.342766 [ThreadId 119] INFO hls:     Consulting the cradle for "Setup.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/hiromi/Documents/Programming/Haskell/git/small-repro", cradleOptsProg = CradleAction: Stack}
2021-03-02 11:44:03.348595 [ThreadId 119] DEBUG hls:    Session loading result: Left [CradleError {cradleErrorDependencies = [], cradleErrorExitCode = ExitSuccess, cradleErrorStderr = ["Multi Cradle: No prefixes matched","pwd: /Users/hiromi/Documents/Programming/Haskell/git/small-repro","filepath: /Users/hiromi/Documents/Programming/Haskell/git/small-repro/Setup.hs","prefixes:","(\"./src/Main.hs\",Stack {component = Just \"small-repro:exe:small-repro\", stackYaml = Nothing})"]}]
2021-03-02 11:44:03.37352 [ThreadId 221] INFO hls:      finish: User TypeCheck (took 0.03s)
2021-03-02 11:44:03.375635 [ThreadId 234] INFO hls:     finish: GetHie (took 0.00s)
2021-03-02 11:44:03.375792 [ThreadId 235] INFO hls:     finish: GenerateCore (took 0.00s)
Files that failed:
 * /Users/hiromi/Documents/Programming/Haskell/git/small-repro/Setup.hs

Completed (1 file worked, 1 file failed)

Paste the logs from the lsp-client, e.g. for VS Code

LSP logs:
[client] run command: "/Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-1.0.0-darwin-8.10.4 --lsp"
[client] debug command: "/Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-1.0.0-darwin-8.10.4 --lsp"
[client] server cwd: undefined
haskell-language-server version: 1.0.0.0 (GHC: 8.10.4) (PATH: /Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-1.0.0-darwin-8.10.4) (GIT hash: 4cd1cf934638881e52b3eba9f70157a4b799c0e9)
Starting (haskell-language-server)LSP server...
  with arguments: LspArguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "brittany",PluginId "class",PluginId "eval",PluginId "floskell",PluginId "fourmolu",PluginId "ghcide-code-actions",PluginId "ghcide-completions",PluginId "ghcide-hover-and-symbols",PluginId "ghcide-type-lenses",PluginId "haddockComments",PluginId "hlint",PluginId "importLens",PluginId "moduleName",PluginId "ormolu",PluginId "pragmas",PluginId "retrie",PluginId "splice",PluginId "stylish-haskell",PluginId "tactic"]
  in directory: /Users/hiromi/Documents/Programming/Haskell/git/small-repro
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
Starting LSP server...
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 2021-03-02 11:43:23.062722 [ThreadId 5] INFO haskell-lsp.runWith:	




haskell-lsp:Starting up server ...
Started LSP server in 0.00s
setInitialDynFlags cradle: Cradle {cradleRootDir = "/Users/hiromi/Documents/Programming/Haskell/git/small-repro", cradleOptsProg = CradleAction: Stack}
2021-03-02 11:43:23.766503 [ThreadId 5] INFO hls:	Registering ide configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri 8879377354893767911 "file:///Users/hiromi/Documents/Programming/Haskell/git/small-repro"], clientSettings = hashed Nothing}
2021-03-02 11:43:23.771596 [ThreadId 93] INFO hls:	hlint:getIdeas:file:NormalizedFilePath "/Users/hiromi/Documents/Programming/Haskell/git/small-repro/src/Main.hs"
2021-03-02 11:43:23.773279 [ThreadId 103] INFO hls:	Consulting the cradle for "src/Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/hiromi/Documents/Programming/Haskell/git/small-repro", cradleOptsProg = CradleAction: Stack}
[Error - 11:43:23] haskell-lsp:incoming message parse error. {"jsonrpc":"2.0","id":1,"result":null} Error in $.result: parsing () failed, expected Array, but encountered Null

[Error - 11:43:23] haskell-lsp:incoming message parse error. {"jsonrpc":"2.0","id":2,"result":null} Error in $.result: parsing () failed, expected Array, but encountered Null

> Using main module: 1. Package `small-repro' component small-repro:exe:small-repro with main-is file: /Users/hiromi/Documents/Programming/Haskell/git/small-repro/src/Main.hs
> Building all executables for `small-repro' once. After a successful build of all of them, only specified executables will be rebuilt.
> small-repro> configure (exe)
> Configuring small-repro-0.1.0.0...
> small-repro> initial-build-steps (exe)
> Configuring GHCi with the following packages: small-repro
> /Users/hiromi/Documents/Programming/Haskell/git/small-repro/.stack-work/install/x86_64-osx/558c152a1bb96869716c728ef95f5578695b79c7caaea744a13c987678024fb0/8.10.4/pkgdb:/Users/hiromi/.stack/snapshots/x86_64-osx/558c152a1bb96869716c728ef95f5578695b79c7caaea744a13c987678024fb0/8.10.4/pkgdb:/Users/hiromi/.stack/programs/x86_64-osx/ghc-8.10.4/lib/ghc-8.10.4/package.conf.d
2021-03-02 11:43:26.976584 [ThreadId 103] INFO hls:	Using interface files cache dir: /Users/hiromi/.cache/ghcide/main-a1f4958c591824e1a2927712572780e3b7d3153e
2021-03-02 11:43:26.976733 [ThreadId 103] INFO hls:	Making new HscEnv[main]
2021-03-02 11:43:26.982718 [ThreadId 202] INFO hls:	hlint:getIdeas:file:NormalizedFilePath "/Users/hiromi/Documents/Programming/Haskell/git/small-repro/src/Main.hs"
2021-03-02 11:43:26.983553 [ThreadId 223] INFO hls:	finish: ModuleName.ghcSession (took 0.00s)
2021-03-02 11:43:26.984296 [ThreadId 246] INFO hls:	finish: Outline (took 0.00s)
2021-03-02 11:43:26.98429 [ThreadId 249] INFO hls:	finish: ModuleName.GetParsedModule (took 0.00s)
2021-03-02 11:43:26.984311 [ThreadId 250] INFO hls:	finish: parsed (took 0.00s)
2021-03-02 11:43:27.007811 [ThreadId 300] INFO hls:	finish: codeLens (took 0.03s)
2021-03-02 11:43:27.007957 [ThreadId 308] INFO hls:	finish:  (took 0.03s)
[Error - 11:43:27] haskell-lsp:incoming message parse error. {"jsonrpc":"2.0","id":3,"result":null} Error in $.result: parsing () failed, expected Array, but encountered Null
@konn konn added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. component: lsp labels Mar 2, 2021
@michaelpj
Copy link
Collaborator

So I guess this is a bug in lsp-types where we are missing that a result can be optional.

@wz1000
Copy link
Collaborator

wz1000 commented Mar 2, 2021

Addressed in haskell/lsp#295

@michaelpj
Copy link
Collaborator

What do we need to do to get this fix into HLS? people keep reporting this because it looks scary!

@wz1000
Copy link
Collaborator

wz1000 commented Mar 17, 2021

We need a new release of lsp-test. /cc @bubba

@berberman berberman linked a pull request Apr 2, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: lsp type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
5 participants