Skip to content

Unexpected exception on notification, please report! #143

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

Closed
aryairani opened this issue Jun 1, 2020 · 4 comments
Closed

Unexpected exception on notification, please report! #143

aryairani opened this issue Jun 1, 2020 · 4 comments
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@aryairani
Copy link

hie/ghcide/haskell-language-server noob here, so I apologize for a possibly-low-quality bug report.

I get a bunch of Exception: user error (Pattern match failure in do expression at src/Development/IDE/Core/Shake.hs:157:5-10) (given in the code block below) when I open my Haskell files. Not sure if this is actually related to the "Unexpected exception on notification" message in the issue title, which I also see in the log, but I don't know that it isn't :)

getIdeGlobalExtras :: forall a . IsIdeGlobal a => ShakeExtras -> IO a
getIdeGlobalExtras ShakeExtras{globals} = do
    Just x <- HMap.lookup (typeRep (Proxy :: Proxy a)) <$> readVar globals
    return $ fromDyn x $ error "Serious error, corrupt globals"

The full log is here: https://gist.github.com/aryairani/90410cce8d5c132b9290329f4d326647

I am using the Atom ide-haskell-hie plugin v0.12.0 with the custom hie-wrapper set to haskell-language-server-wrapper.

Keep up the good work!

@jneira jneira added component: ghcide status: needs repro type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jun 1, 2020
@ndmitchell
Copy link
Collaborator

Oh dear! Sadly, our error message is pretty crap, and doesn't tell us which global is missing, which would be by far the most useful piece of information. I've sent a patch to improve that: haskell/ghcide#598

Does this reproduce reliably? Or is it a one-off after a sequence of edits that you can't reproduce?

@ndmitchell
Copy link
Collaborator

I see "Client does not support watched files. Falling back to OS polling" in the logs, and use of Atom. My guess is most testing is done on clients which do support watched files, so that's seems like a possible lead.

@pepeiborra
Copy link
Collaborator

I see "Client does not support watched files. Falling back to OS polling" in the logs, and use of Atom. My guess is most testing is done on clients which do support watched files, so that's seems like a possible lead.

That's a good lead indeed. Even more, there's a few DidChangeWatchedFiles notifications for random files a few lines below:

2020-06-01 12:00:14.849609 [ThreadId 7] - <--2--{"result":[],"jsonrpc":"2.0","id":1}
2020-06-01 12:00:19.661629 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"workspace/didChangeWatchedFiles","params":{"changes":[{"uri":"file:///Users/arya/unison/master/.stack-work/install/x86_64-osx/98c5c320d01fff2fa8b4023e473195d63b1dfd1f146602174ea52fc2c66bab77/8.6.5/pkgdb/easytest-0.1-GHUNtMcGbspKNzFvNGkuQU.conf","type":3},{"uri":"file:///Users/arya/unison/master/.stack-work/install/x86_64-osx/98c5c320d01fff2fa8b4023e473195d63b1dfd1f146602174ea52fc2c66bab77/8.6.5/pkgdb/package.cache28730-0.tmp","type":3},{"uri":"file:///Users/arya/unison/master/.stack-work/stack.sqlite3-journal","type":3},{"uri":"file:///Users/arya/unison/master/.stack-work/install/x86_64-osx/98c5c320d01fff2fa8b4023e473195d63b1dfd1f146602174ea52fc2c66bab77/8.6.5/pkgdb/package.cache","type":1},{"uri":"file:///Users/arya/unison/master/.stack-work/install/x86_64-osx/98c5c320d01fff2fa8b4023e473195d63b1dfd1f146602174ea52fc2c66bab77/8.6.5/pkgdb/package.cache","type":1}]}}

So the problem is obvious: the client is very buggy. It is sending DidChangeWatchedFiles notifications even though it doesn't advertise support for them, and we did not request them.

The GetFileExists rules use a global which gets installed only when the client supports watched files. It is required in modifyFileExists which is called from the DidChangeWatchedFiles notification handler.

We can patch this on our side by registering the global unconditionally, but @aryairani you should probably switch to another plugin/editor combination

@pepeiborra
Copy link
Collaborator

I have moved the issue to the ghcide tracker where it belongs, thanks for the report @aryairani

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

4 participants