zbirenbaum / copilot.lua

Fully featured & enhanced replacement for copilot.vim complete with API for interacting with Github Copilot
MIT License
2.45k stars 67 forks source link

Errors on each keypress when offline #165

Open divan opened 1 year ago

divan commented 1 year ago

When there is no internet connection available, plugin seems to throw error on each keypress:

RPC[Error] code_name = InternalError, message = "Request getCompletions failed with message: getaddrinfo ENOTFOUND api.github.com"

This seems to be described in https://github.com/zbirenbaum/copilot.lua/issues/93, but suggested solution is disable auto trigger of Copilot. This might be an option for some people, but I prefer it to be enabled by default, just don't show error when this error is encountered.

The problem is particularly nasty as this error prevents from normal typing – I need to press Enter to dismiss an error and then type the next character. Basically it makes typing impossible without internet.

Any idea how to prevent it from throwing an error?

I'm using Astronvim, not sure if the behaviour of the plugin is the same for all nvim configurations. Could anyone verify if they having the same behaviour?

MunifTanjim commented 1 year ago

Just disable it? :Copilot disable

divan commented 1 year ago

Just disable it? :Copilot disable

Actually it took some time and googling to even find that this issue is caused by Copilot. As I used Astronvim, my initial thought was that it's some git(hub) plugin I'm unaware about. Nothing in the error messages hints to Copilot.

Disabling and enabling back everytime you're on the bad network or without network is a workaround, but not really a solution. There is no reason to throw this error at all (I kinda expect that Copilot won't work without internet, it's expected, no error to react here). Errors should be thrown only when app want's human to intervene and do something. Otherwise it should just fail silently. Definitely not to disrupt a core functionality of the editor.

MunifTanjim commented 1 year ago

Weirdly, if I disconnect my network, I get these in the ~/.local/state/nvim/lsp.log file:

[ERROR][2023-05-07 22:19:53] .../vim/lsp/rpc.lua:734    "rpc"   "node"  "stderr"    "[ERROR] [default] [2023-05-07T16:19:53.216Z] Request Error: The pending stream has been canceled (caused by: getaddrinfo ENOTFOUND copilot-proxy.githubusercontent.com)\n"
[ERROR][2023-05-07 22:19:53] .../vim/lsp/rpc.lua:734    "rpc"   "node"  "stderr"    "[ERROR] [ghostText] [2023-05-07T16:19:53.217Z] Error on ghost text request FetchError: The pending stream has been canceled (caused by: getaddrinfo ENOTFOUND copilot-proxy.githubusercontent.com)\n"
[ERROR][2023-05-07 22:19:57] .../vim/lsp/rpc.lua:734    "rpc"   "node"  "stderr"    "ApplicationInsights:Sender [\n  'Ingestion endpoint could not be reached. This batch of telemetry items has been lost. Use Disk Retry Caching to enable resending of failed telemetry. Error:',\n  [\n    \"[object Error]{ stack: 'Error: getaddrinfo ENOTFOUND copilot-telemetry.githubusercontent.com\\n\" +\n      \"    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:26)', message: 'getaddrinfo ENOTFOUND copilot-telemetry.githubusercontent.com', name: 'Error'\"\n  ]\n]\n"

But neovim doesn't print any error in the cmdline. So it doesn't interrupt text insertion.

Can you share how you're setting up lsp and copilot?

MunifTanjim commented 1 year ago

Also what's the output of :Copilot version?

divan commented 1 year ago

@MunifTanjim hmm, I checked my lsp.log and it's same as yours upon going offline. But here is a bit more weirdness to the story:

When I try to reproduce it on the external monitor or with a small enough font – there is no error thrown. But once I use larger font size (and/or laptop display) – then it appears. Literally by changing terminal font size the issue appears or disappears.

Screenshot 2023-05-07 at 20 14 41

It's probably has something to do how Astronvim handles errors display, but as I'm not nvim power use, I have no idea where to even look at.

Also what's the output of :Copilot version?

copilot.vim 1.8.4
copilot.lua 8b0fd23747ef82154ef9f919c75623156465cc89
copilot/dist/agent.js 1.84.0
Node.js 20.0.0
MunifTanjim commented 1 year ago

Also what's the output of :Copilot version?

copilot.vim 1.8.4
copilot.lua 8b0fd23747ef82154ef9f919c75623156465cc89
copilot/dist/agent.js 1.84.0
Node.js 20.0.0

Usually that output also contains neovim's version 🤔 What's the version of Neovim you're using?

divan commented 1 year ago

@MunifTanjim

:version

NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@HMBRW-A-001-M1-004.local

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

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.8.0/share/nvim"
Bekaboo commented 7 months ago

Any workaround for this? The error message is quite annoying when you have slow internet connection. I would rather just hide the message.

teocns commented 6 months ago

I think you can write up an autocmd that suppresses outputs for the copilot plugin, but besides :Copilot disable I think there's no workaround atm