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

Error with gopls #19

Closed
ssoriche opened this issue Jan 27, 2022 · 18 comments
Closed

Error with gopls #19

ssoriche opened this issue Jan 27, 2022 · 18 comments
Labels
bug Something isn't working

Comments

@ssoriche
Copy link

I'm receiving the following error message when editing Go with gopls running:

Error executing vim.schedule lua callback: ...e/nvim/site/pack/packer/start/fidget.nvim/lua/fidget.lua:77: invalid option '%544' to 'format'
stack traceback:
        [C]: in function 'format'
        ...e/nvim/site/pack/packer/start/fidget.nvim/lua/fidget.lua:77: in function 'fmt'
        ...e/nvim/site/pack/packer/start/fidget.nvim/lua/fidget.lua:153: in function ''
        vim.lua: in function ''
        vim.lua: in function <vim.lua:0>
Press ENTER or type command to continue

The error repeats over and over again, so far I haven't been able to find the end of it.

@ssoriche
Copy link
Author

I was able to determine that the value of pad at fidget.lua:77 is %5445s which leads me to believe that the value accepted by string.format() has a maximum.

@j-hui j-hui added the bug Something isn't working label Jan 27, 2022
@j-hui
Copy link
Owner

j-hui commented Jan 27, 2022

Gopls must be making some enormous progress to warrant some 5445-character long message...

There's obviously no way that even fits on a screen, so I'll probably just cap it at some sane amount, but that does beg the question: what should the behavior be when we encounter these kinds of unreasonably long messages? Should I just truncate it?

@ssoriche
Copy link
Author

I used %99s when the length was longer than 99, I think this too is too long. It appears that gopls is finding some symlinks in the repository I'm working on and letting me know that it isn't going to follow them.

I could probably print the whole line to know of certain what it is getting stuck on.

I think truncating is a reasonable result, perhaps with an ellipse to indicate such.

@ttys3
Copy link

ttys3 commented Jan 28, 2022

I got this too.

edit go.mod with wrong format or value:

Error executing vim.schedule lua callback: ...e/nvim/site/pack/packer/start/fidget.nvim/lua/fidget.lua:77: invalid option '%161' to 'format'
stack traceback:
        [C]: in function 'format'
        ...e/nvim/site/pack/packer/start/fidget.nvim/lua/fidget.lua:77: in function 'fmt'
        ...e/nvim/site/pack/packer/start/fidget.nvim/lua/fidget.lua:153: in function ''
        vim.lua: in function ''
        vim.lua: in function <vim.lua:0>

@j-hui
Copy link
Owner

j-hui commented Jan 28, 2022

@ttys3 can you check out the truncate-messages branch and see if that fixes your problem? Or at least provide a public repo I can use to reproduce this problem?

@ttys3
Copy link

ttys3 commented Jan 28, 2022

@j-hui OK, I'll upload a zip with demo project to re-produce this:

image

fidget-nvim-go-mod-demo.zip

steps to reproduce

gopls version:

gopls version
golang.org/x/tools/gopls v0.7.5
    golang.org/x/tools/gopls@v0.7.5 h1:8Az52YwcFXTWPvrRomns1C0N+zlgTyyPKWvRazO9GG8=

go version: go version go1.17.6 linux/amd64

download https://github.com/j-hui/fidget.nvim/files/7959009/fidget-nvim-go-mod-demo.zip

and unzip it.

cd fidget-nvim-go-mod-demo

nvim go.mod

the error occurs

@ttys3
Copy link

ttys3 commented Jan 28, 2022

@j-hui tried truncate-messages branch, does not fix the problem

@j-hui
Copy link
Owner

j-hui commented Jan 28, 2022

thanks @ttys3 ! I was able to repro the issue.

Turns out string.format does not support any format specifier with n > 99. Can you try again with the latest commit I pushed to that branch?

@j-hui
Copy link
Owner

j-hui commented Jan 28, 2022

(Also, why is this message even coming through the progress notification? This seems like a diagnostic message rather than a progress message. And why does the task never complete? Perhaps we should file an issue to gopls maintainers.)

@ssoriche
Copy link
Author

I have not tried the branch (yet), but during my own experimentation with passing %99s to string.format() I noticed the same thing, gopls task never completed, and the spinner used considerable CPU.

@j-hui
Copy link
Owner

j-hui commented Jan 28, 2022

@ttys3 may I create an issue on gopls with the test repo you sent me?

@ssoriche
Copy link
Author

Using the truncate-messages branch, I was able to successfully start neovim with fidget displaying progress, and the task did stop.

I'll continue to use this branch throughout the day and if I see any different behaviour report it here.

@ttys3
Copy link

ttys3 commented Jan 28, 2022

@ttys3 may I create an issue on gopls with the test repo you sent me?

Of course, it is just a demo and does not involve any private information

@ssoriche
Copy link
Author

ssoriche commented Jan 28, 2022

I am getting the constant running gopls again, but this time I can see the message because it is truncated:

err: exit status 2: stderr: warning: ignoring symlink

This leaves the fidget status in the corner, with the spinner continuing.

Edit: just saw your comment here golang/go#50885 (comment)
which seems like it would be related.

j-hui added a commit that referenced this issue Jan 29, 2022
* Truncate text wider than the width of current window

* Truncate text longer than 99 chars

* Add FAQ about messages being cut short

* Fix some links in documentation
@j-hui
Copy link
Owner

j-hui commented Jan 29, 2022

I landed #20 onto main, so this plugin should no longer spew errors when encountering extremely long messages.

The remaining issue with gopls spewing an extremely verbose diagnostic error and refusing to complete is tracked by golang/go#50885. If it turns out that the correct thing to do is to indeed timeout, I'll create another issue for that.

@ssoriche
Copy link
Author

Just wanted to add on to this with some information. I just had to force quit out of my terminal program with Activity Monitor telling me that neovim was using 100GB+ of memory. Fidget was running waiting for an update from gopls while I was involved in a meeting.

@j-hui
Copy link
Owner

j-hui commented Jan 31, 2022

@ssoriche I'm very sorry to hear that. There's obviously no reason Fidget should need to allocate that much memory; I'll have to investigate where the leak is coming from.

@ssoriche
Copy link
Author

ssoriche commented Feb 1, 2022

Thank you @j-hui, I just wanted to document that gopls decision on how to handle errors is impacting.

ttys3 added a commit to ttys3/nvim-config that referenced this issue Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants