graphiql: lsp server doesn't start using coc.vim
I’m having the same issue described here:
https://github.com/neoclide/coc.nvim/issues/3687
and here:
https://stackoverflow.com/questions/68750196/graphql-lsp-with-coc-neovim
I gather these logs:
vim version: NVIM v0.7.0-dev+1233-gabbc9148d
node version: v17.5.0
coc.nvim version: 0.0.80-a554a31c 2022-03-11 19:04:48 +0800
coc.nvim directory: $HOME/.vim/bundle/coc.nvim
term: tmux
platform: linux
## Log of coc.nvim
2022-03-11T09:17:35.905 INFO (pid:3255126) [services] - registered service "languageserver.graphql"
2022-03-11T09:17:35.908 INFO (pid:3255126) [services] - graphql state change: stopped => starting
2022-03-11T09:17:35.935 INFO (pid:3255126) [plugin] - coc.nvim initialized with node: v17.5.0 after 87ms
2022-03-11T09:17:35.940 INFO (pid:3255126) [language-client-index] - Language server "languageserver.graphql" started with 3255169
2022-03-11T09:17:36.264 INFO (pid:3255126) [services] - graphql state change: starting => running
2022-03-11T09:17:36.268 INFO (pid:3255126) [services] - service languageserver.graphql started
2022-03-11T09:17:36.312 INFO (pid:3255126) [services] - graphql state change: running => stopped
2022-03-11T09:17:36.312 INFO (pid:3255126) [services] - graphql state change: stopped => starting
2022-03-11T09:17:36.315 INFO (pid:3255126) [language-client-index] - Language server "languageserver.graphql" started with 3255218
2022-03-11T09:17:36.633 INFO (pid:3255126) [services] - graphql state change: starting => running
2022-03-11T09:17:36.678 INFO (pid:3255126) [services] - graphql state change: running => stopped
2022-03-11T09:17:36.678 INFO (pid:3255126) [services] - graphql state change: stopped => starting
2022-03-11T09:17:36.680 INFO (pid:3255126) [language-client-index] - Language server "languageserver.graphql" started with 3255249
2022-03-11T09:17:36.991 INFO (pid:3255126) [services] - graphql state change: starting => running
2022-03-11T09:17:37.034 INFO (pid:3255126) [services] - graphql state change: running => stopped
2022-03-11T09:17:37.034 INFO (pid:3255126) [services] - graphql state change: stopped => starting
2022-03-11T09:17:37.037 INFO (pid:3255126) [language-client-index] - Language server "languageserver.graphql" started with 3255260
2022-03-11T09:17:37.342 INFO (pid:3255126) [services] - graphql state change: starting => running
2022-03-11T09:17:37.386 INFO (pid:3255126) [services] - graphql state change: running => stopped
2022-03-11T09:17:40.344 INFO (pid:3255126) [attach] - receive notification: showInfo []
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 65 (33 by maintainers)
Commits related to this issue
- LSP on config change bug fixes for #2230 (#2271) — committed to graphql/graphiql by acao 2 years ago
- ensure correct version of vscode-languageserver-protocol resolved Between MINOR version of vscode-languageserver-protocol, the version of vscode-jsonrpc that it depends on changed in **MAJOR** versio... — committed to xuanduc987/graphiql by xuanduc987 2 years ago
- fix: ensure compatible version of vscode-languageserver-protocol resolved Between MINOR version of vscode-languageserver-protocol, the version of vscode-jsonrpc that it depends on changed in **MAJOR*... — committed to xuanduc987/graphiql by xuanduc987 2 years ago
- upgrades the vscode-languageserver reference implementation under the hood. seems to work fine for IPC in vscode-graphql at least! hopefully this solves #2230 once and for all! — committed to graphql/graphiql by acao 2 years ago
- upgrades the vscode-languageserver reference implementation under the hood. seems to work fine for IPC in vscode-graphql at least! hopefully this solves #2230 once and for all! — committed to graphql/graphiql by acao 2 years ago
- upgrades the `vscode-languageserver` and `vscode-jsonrpc` reference implementations under the hood. also upgrades `vscode-languageclient` to match. seems to work fine for IPC in `vscode-graphql` at le... — committed to graphql/graphiql by acao 2 years ago
@benjie thank you! Hopefully someone has time or interest. @stonexer perhaps you‘d be interested in taking a look? Both vscode and nvim coc have changed their exception handling all of a sudden and I just resolved the former.
I think it’s just a lingering uncaught exception somewhere, or just that the LSP server is behaving differently because of something the nvim coc client expects. I tried debugging the LSP server with vim to log to output channel uncaught exceptions using
process.on(), but i couldn’t get my vim instance to load the locally built LSP server I was trying to debug, or this was not showing an uncaught exception. I at least figured out some of the COC commands for debugging the lsp server in vim.@wongjiahau glad to hear it’s not just me and that there are workarounds for both CoC and the native LSP client.
The other issue could be the difference between what we are returning to the client in terms of specified capabilities, and what we are using.
I will set up nvim coc later this week or next and take a look, I am on holiday this week
I am having the same issue with the version 3.2.27, using vanilla config provided by
neovim/nvim-lspconfigso still no fix…There are others having the same problem
3.3.0of the cli has been released! i think this should take care of it. if anyone else is having issues after this update, please re-openThank you very much @acao
graphql-language-service-cli@3.3.0-canary-0ab0e498.0works for me.Just another update on this before doing some more digging.
I have managed to get this working by building
graphql-language-service-clilocally and then symlinking that package instead of using the downloaded one.For my installation this looks like:
As to why the downloaded package differs from a locally-build one—I do not know.
I am curious to hear if this also resolves the issue for others.
3.2.27as well usingneovim/nvim-lspconfig.My logs show the following errors:
Haven’t looked into it deeply, but quick skim looks like it may be related to the GraphQLCache object on the MessageProcessor.
@acao tagging you because you asked for a stack trace above
I’m afraid the fix is not enough for yarn user like me (install graphql-language-service-cli with yarn global add)
Go to
yarn global dir, and runyarn why vscode-languageserver-protocolshowyarn doesn’t select the hoisted version for
vscode-languageserver#vscode-languageserver-protocol, but instead use the latest version satisfy version range specified in vscode-languageserver package.json.I guess we have to upgrade vscode-languageserver to latest version to fix this completely (which could be very time consuming)
Workaround: add
resolutionsfield to package.json file inyarn global dirforce yarn to choose vscode-languageserver-protocol@3.15.33.2.30works for me too! Thank you @acao and @howlinbash 🙏Thanks @acao and @howlinbash — works great now 🙏
I can’t say anything about coc, but
3.2.30fixed the graphql language service with the neovim lsp client (which I think was the same issue)! Thanks for the release 🙏🏻I have the same problem. I wont be able to do much work on it today but I can offer a slight improvement to graphql-lsp binary.
https://github.com/graphql/graphiql/blob/main/packages/graphql-language-service-cli/src/cli.ts#L113-L115
This line should be changed to
process.stderr.write(Also I console.logged the error and I got a stack trace from
:CocCommand workspace.showOutputThis line in the vscode-jsonrpc is returning undefined from the write method
I will have a little bit more time to look at this next week perhaps but thought I should at least share these findings for now.
@acao, Would you like me to make a PR for the
stdout --> stderrchange?Hey @acao very sorry for the delay in replying. I’d be happy to schedule some time to have a look at this together 😄 Not sure what the best way is to get this arranged, but I can hop on a Discord or Zoom (or equiv) sometime that suits both of our timezones
@acao I’m not using Berry so
global whydidn’t work, but can confirm that the version of CLI I have installed isand my global installation for
graphql-language-service-serveris:Another release inbound! Be sure that graphql-language-service-server is the latest version. If that doesn’t work, another easier workaround that might work would be to
npm install -g graphql-language-service-cli@latest graphql-language-service-server@latestin case for some reason CLI is causing an outdated server version to resolve.@wilhelmeek i could not get nvim coc working but I will try to trigger a new release of the language server soon to fix this issue. Following the github actions log for the last cli/server releases, it was a clean build from source & release, so I still don’t understand how this could happen, but hopefully another deploy just resolves it
@wilhelmeek I got it working too by building the executable locally. The one installed from
npmis not working.This is what I did:
Then in
coc-settings.json, change the following:@acao enjoy your holiday! I’ll update here if I manage to resolve this in the mean time.
For posterity I am using
.graphqlrc.yamland have verified that thegraphql-lspexecutable on my PATH is version3.2.19.it works for me
does this canary release work for y’all?
graphql-language-service-cli@3.2.19-canary-5991895d.0aka
npm install -g graphql-language-service-cli@3.2.19-canary-5991895d.0Another change I had to make because it kept crashing “randomly”
https://github.com/graphql/graphiql/blob/e793f887b28af471c4d55522a57b61ebadafd14f/packages/graphql-language-service-server/src/MessageProcessor.ts#L291
@acao I finally make it work!
I changed these lines from here:
https://github.com/graphql/graphiql/blob/e793f887b28af471c4d55522a57b61ebadafd14f/packages/graphql-language-service-server/src/startServer.ts#L369
to
The only changes I’ve made have been to update the babel parser, which shouldn’t be causing this I imagine - can coc.vim use a different logging level to show some useful information?