neovimhaskell / nvim-hs

Neovim API for Haskell plugins as well as the plugin provider
Other
267 stars 18 forks source link

Not work when compiled with lts-10.0 #61

Closed uuhan closed 6 years ago

uuhan commented 6 years ago

When use lts-10.0 snapshot to compile nvim-hs, It is problematic to work. I looked into the logger, found some Error message:

[Context : ERROR] Converting Exception to Error message: thread blocked indefinitely in an STM transaction [Neovim.Main : ERROR] Error initializing plugins: thread blocked indefinitely in an STM transaction [Neovim.Main : ERROR] thread blocked indefinitely in an STM transaction

Hangs in this line: https://github.com/neovimhaskell/nvim-hs/blob/868a86933ecf880eef8f8a092d4fdd90091b4708/library/Neovim/RPC/SocketReader.hs#L74

saep commented 6 years ago

Thanks for reporting!

I can reproduce it and will try to find the actual cause. Seems to be an odd bug since it hasn't happened in previous lts versions (I think).

uuhan commented 6 years ago

I finally found that the root cause is: https://github.com/neovimhaskell/nvim-hs/blob/868a86933ecf880eef8f8a092d4fdd90091b4708/library/Neovim/Main.hs#L171 When call by nvim through rpc call, get from stdin ,

 _ -> do
     hGetSome stdin 10 -- hangs here!
     run stdout stdin

But if run nvim-hs from command line, the stdin works fine. Maybe something wrong with stdin of ghc-8.2.2 @saep

saep commented 6 years ago

Thanks for looking into this! Adding NoBuffering to stdout at that location fixes the hanging for me (see #62). Do you mind testing that yourself? If it works for you I'll make a new release on hackage.

uuhan commented 6 years ago

@saep Yes, setting NoBuffering to stdout solve the problem. Would you mind tell me why the stdout should be set to  NoBuffering with ghc-8.2.2 ?Thanks.

saep commented 6 years ago

After a bit of digging, I learned that the sinkHandle function of the conduit-extra library changed it's behavior to not flush on every element anymore. The newer version of the module has a sinkHandleFlush variant that would have to be used here if stdout uses some kind of buffering.

A proper fix is probably to figure out the version when the behavior changed and add an #ifdef for compatibility. I suspect that the TCP and UNIX-Socket handles may exhibit the same problem because of this.

edit: typo

saep commented 6 years ago

I created a release that should address this issue.