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

Language server crashes on nvim #927

Closed
mosheavni opened this issue May 24, 2022 · 6 comments
Closed

Language server crashes on nvim #927

mosheavni opened this issue May 24, 2022 · 6 comments
Labels
editor/neovim https://neovim.io/

Comments

@mosheavni
Copy link

mosheavni commented May 24, 2022

Server Version

0.27.0

Terraform Version

Terraform v1.1.9
on darwin_amd64

Your version of Terraform is out of date! The latest version
is 1.2.0. You can update by downloading from https://www.terraform.io/downloads.html

Client Version

NVIM v0.7.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Monterey

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.7.0/share/nvim"

Run :checkhealth for more info

Terraform Configuration Files

resource "aws_alb" "name" {
  name = "test"
  subnets = ["1","2"]
  load_balancer_type = "testt"
  idle_timeout = "900"
  tags_all = {
    env = "prod"
  }
}

Log Output

https://gist.github.com/mosheavni/c5914746d4134779c6f3cb1481e2d597

Expected Behavior

Completion wouldn't crash the server

Actual Behavior

After a few completions on the aws module, I get a diagnostic error:

Argument or block definition required: An argument or block definition is required here. To set an argument, use the equals sign "=" to introduce the argument value.

and the language server doesn't work anymore:

2022/05/23 22:47:55 opts.go:218: Discarding error from notification to "textDocument/didChange": Old version (1015) received, current version is 1015. Unable to update file:///Users/mavni/Repos/terraform/prod/eu-west-1/redis/data.tf. This is likely a bug, please report it.

Although the process is still live and keeps on producing:

2022/05/23 22:47:56 opts.go:218: Discarding error from notification to "textDocument/didChange": file:///Users/mavni/Repos/terraform/prod/eu-west-1/redis/data.tf: document not found

many times after.

Steps to reproduce

  1. Create a minimal-init.lua file:
mkdir /tmp/tfls-crash-test/
cd /tmp/tfls-crash-test/
curl -sLO https://gist.githubusercontent.com/mosheavni/4adb8b498e369849a6d301294332fd8e/raw/5ac421a3ca0f4611980630769e046b3b60647f85/minimal_init.lua
  1. Create a simple terraform with aws provider file, and open that file with neovim >= 0.7
cd /tmp/tfls-crash-test/
cat <<EOF > main.tf
resource "aws_alb" "name" {
  name = "test"
  subnets = ["1","2"]
  load_balancer_type = "testt"
  idle_timeout = "900"
  tags_all = {
    env = "prod"
  }
}
EOF
nvim -nu minimal_init.lua main.tf
  1. Play around with the completion (ctrl+space) inside the aws block, add tags and tags_all blocks, in about ~5 minutes the server will crash with the above mentioned error logs
@radeksimko radeksimko added upstream editor/neovim https://neovim.io/ and removed upstream labels May 24, 2022
@radeksimko
Copy link
Member

Hi @mosheavni
Thank you for the report.

The mentioned diagnostic error is just a noisy diagnostic we plan to address in #326

The following error indicates the real root cause:

Discarding error from notification to "textDocument/didChange": Old version (1015) received, current version is 1015. Unable to update file:///Users/mavni/Repos/terraform/prod/eu-west-1/redis/data.tf. This is likely a bug, please report it.

Generally per LSP I'd expect clients (including the NeoVIM one) to never send the same version twice. I experienced a similar bug in Sublime Text, which has led to a successful fix: sublimelsp/LSP#1470 sublimelsp/LSP#1514

Have you tried reporting this to NeoVIM?

@mosheavni
Copy link
Author

sublimelsp/LSP#1470

If the clients sends the version twice, can't terraform-ls notice that and ignore it?
If more than one client experiences an issue with the server, I think it's better approaching this from the server side, no?

@radeksimko
Copy link
Member

radeksimko commented May 24, 2022

If the clients sends the version twice, can't terraform-ls notice that and ignore it?

I'm inclined to agree - it's probably the right pragmatic solution - see #310

However I would still encourage you to report this in NeoVIM, as this is clearly a bug there which should be addressed.

@mosheavni
Copy link
Author

Opened:
neovim/neovim#18734

@radeksimko
Copy link
Member

I'm going to close this as we can continue to track the discussed server changes as part of #310

Thanks for the detailed report and for filing the issue in NeoVIM.

@github-actions
Copy link

github-actions bot commented Jul 1, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor/neovim https://neovim.io/
Projects
None yet
Development

No branches or pull requests

2 participants