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

After enabling NextLS, connection to server is erroring #53

Closed
fhunleth opened this issue Aug 24, 2023 · 13 comments
Closed

After enabling NextLS, connection to server is erroring #53

fhunleth opened this issue Aug 24, 2023 · 13 comments

Comments

@fhunleth
Copy link

With the Credo Language server disabled and NextLS enabled, I'm getting the following error on Ubuntu 22.04.4.

[Error - 9:28:02 AM] Client NextLS: connection to server is erroring. Shutting down server.
[Error - 9:28:02 AM] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: starting
	at _.shutdown (/home/fhunleth/.vscode/extensions/elixir-tools.elixir-tools-0.8.0/dist/extension.js:2:96701)
	at _.stop (/home/fhunleth/.vscode/extensions/elixir-tools.elixir-tools-0.8.0/dist/extension.js:2:96282)
	at _.stop (/home/fhunleth/.vscode/extensions/elixir-tools.elixir-tools-0.8.0/dist/extension.js:2:258296)
	at _.handleConnectionError (/home/fhunleth/.vscode/extensions/elixir-tools.elixir-tools-0.8.0/dist/extension.js:2:102789)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)

I'm also getting an error with NextLS timing out on MacOS, but it didn't have a stack trace.

This is my first try at enabling NextLS. I did get the dialog box to download it and the nextls binary prints out help when I manually run it.

I'm using the stdio adapter. When I tried the tcp adapter, I received the same stack trace.

Any ideas on debugging this?

@mhanberg
Copy link
Contributor

Would you mind running through the troubleshooting steps in the Next LS README and report back?

@matt-glover
Copy link

I had a similar experience on Ubuntu 22.04 trying it out just now with both the default install and then switching VSCode to tcp mode.

After the errors I manually started Next LS in tcp mode on port 9000 in a terminal. I then opened VSCode with the extension in tcp mode and VSCode started building my repo via the extension / Next LS. Haven't experimented with any other configurations yet.

@fhunleth
Copy link
Author

I haven't gotten a chance to review the troubleshooting steps yet, but I'll do it later this evening!

@fhunleth
Copy link
Author

I can confirm that manually starting Next LS in TCP mode in another terminal works for me too. This is on MacOS.

@jarrodmoldrich
Copy link

jarrodmoldrich commented Aug 25, 2023

I also experienced this issue on MacOS and then followed the troubleshooting steps. I tried epmd -daemon and that led me to the next issue.

[NextLS] * vix (Hex package)
  the dependency is not available, run "mix deps.get"
... etc

Elixir was already in path in zsh. So then installing code (as per next applicable step in troubleshooting) to the command line and launching from there fixed the issue

[NextLS] Compiled services!

Launching from the command line and having the elixir daemon running is probably not the default for most users, so it might be worth pointing MacOS users towards the troubleshooting.

Thanks for you work. I look forward to trying out NextJS 🙂

@mhanberg
Copy link
Contributor

Launching from the command line and having the elixir daemon running is probably not the default for most users, so it might be worth pointing MacOS users towards the troubleshooting.

erlang is supposed to start epmd if it isn't already started, but that doesn't seem to be the case actually (or maybe isn't the case in how we launch the nextls release.

I hope to remove the need for epmd (elixir-tools/next-ls#204) soon, and the possibility of not needed a local elixir/otp in your path is also something on the horizon.

@fhunleth
Copy link
Author

fhunleth commented Aug 27, 2023

I tried running the VS Code extension under a JS debugger. I'm getting an exception about a Content-Length header not being found. I tried clicking around the debugger to get more context without luck.

However, I changed the NEXTLS_AUTO_UPDATE line to false and that makes the extension work for me.

I haven't had a chance to track this down any farther to how this propagates to an HTTP header warning in Javascript rather than Elixir.

@mhanberg
Copy link
Contributor

mhanberg commented Aug 27, 2023

Hmm, interesting, thanks for finding that out!

so, that is a header from JSON RPC (not HTTP), which LSP clients and servers use to talk to each other. so that implies that the server is sending a malformed payload to the client, which VSCode is rather fragile to (some clients like nvim are more resistant to malformed payloads)

Let me check out what could possibly be happening. can you tell me what version of nextls is currently installed?

you can do ~/.cache/elixir-tools/nextls/bin/nextls --version to find that.

@mhanberg
Copy link
Contributor

I suspect something is just being printed to stdout on accident which is clobbering VSCode.

@fhunleth
Copy link
Author

$ ~/.cache/elixir-tools/nextls/bin/nextls --version
0.10.3

@mhanberg
Copy link
Contributor

Yeah I thought I disabled logging enough for Req but there's a chance it's logging somewhere other than the module I turned it off for.

@fhunleth
Copy link
Author

fhunleth commented Aug 28, 2023

I redirected logging to stderr so that the error message would show up in VSCode. That PR is at elixir-tools/next-ls#208.

Now that I see the error, it's:

20:41:47.573 [error] Task #PID<0.196.0> started from NextLS.DynamicSupervisor terminating
** (CaseClauseError) no case clause matching: {:ok, %Req.Response{status: 403, headers: [{"date", "Mon, 28 Aug 2023 00:41:47 GMT"}, {"server", "Varnish"}, {"strict-transport-security", "max-age=31536000; includeSubdomains; preload"}, {"x-content-type-options", "nosniff"}, {"x-frame-options", "deny"}, {"x-xss-protection", "1; mode=block"}, {"content-security-policy", "default-src 'none'; style-src 'unsafe-inline'"}, {"access-control-allow-origin", "*"}, {"access-control-expose-headers", "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-RateLimit-Used, X-RateLimit-Resource, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset"}, {"content-type", "application/json; charset=utf-8"}, {"referrer-policy", "origin-when-cross-origin, strict-origin-when-cross-origin"}, {"x-github-media-type", "github.v3; format=json"}, {"x-ratelimit-limit", "60"}, {"x-ratelimit-remaining", "0"}, {"x-ratelimit-reset", "1693184025"}, {"x-ratelimit-resource", "core"}, {"x-ratelimit-used", "60"}, {"content-length", "277"}], body: %{"documentation_url" => "https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting", "message" => "API rate limit exceeded for x.y.z.w. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)"}, private: %{}}}
    (next_ls 0.10.3) lib/next_ls/updater.ex:19: NextLS.Updater.run/1
    (elixir 1.15.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
Function: &NextLS.Updater.run/1
    Args: [[binpath: "/Users/fhunleth/.cache/elixir-tools/nextls/bin/nextls", api_host: "https://api.github.com", github_host: "https://github.com", current_version: %Version{major: 0, minor: 10, patch: 3}, logger: #PID<0.194.0>]]

Looks like I use GitHub too much and the error might have magically gone away if I waited a little bit longer.

@mhanberg
Copy link
Contributor

Frank's issue fixed in elixir-tools/next-ls#208

@matt-glover @jarrodmoldrich if y'all continue to have issues, please feel free to open another bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants