vscode-neovim: bug: vscode-neovim is repeatedly locking up in Insert Mode and not responding to ESC or Ctrl-[ to return to Normal Mode

Check the following:

  • I have tried setting vscode-neovim.neovimClean in VSCode settings and restarting VSCode.
  • I have read the vscode-neovim docs.
  • I have searched existing (closed!) issues.

Neovim version (nvim -v)

NVIM v0.10.1 (0.10.1+g7e194f0d0)

Operating system/version

Windows 10

Problem (including log messages)

I’m repeatedly getting stuck in Insert Mode. During a typical dev session (6-8 hours) this occurs 1-3 times, nvim will refuse to leave insert mode. Both ESC and Ctrl-[ fail to work and, if I move to other tabs, they will also be stuck in insert mode. My only recourse is to Save via the menu and run ‘Developer: Reload Window’ which becomes rather annoying. I always run with ‘vscode-neovim.neovimClean’ set with no local config changes to nvim (as vanilla as you can get).

I have attached all of the log entries from today. I didn’t see anything out of the ordinary, unfortunately. I’ll update the issue when I check the logs while experiencing the issue again. vscode-neovim-excerpt.log

My Setup: Windows 10 [vscode 1.93.1|nvim 0.10.1|vscode-neovim 1.18.12]—REMOTE—>Ubuntu 22.04 Server

Steps To Reproduce

  1. Install/Config Windows 10 [vscode 1.93.1|nvim 0.10.1|vscode-neovim 1.18.12]—REMOTE—>Ubuntu 22.04 Server
  2. Edit python file moving between modes
  3. Within 3 hours, Stuck in Insert Mode will occur
  4. Reload Window, rinse and repeat

Expected Behavior

nvim will allow normal editing, traversal between modes, and vim motions. Other than this issue, this is what I normally observe and expect. It is only recently that this lockup has started occurring. With documented exceptions, I expect it to behave similar to vanilla nvim in a terminal.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 6
  • Comments: 15 (1 by maintainers)

Most upvoted comments

I seems that switching between github co-pilot and the editor window always triggers this issue. Also auto complete triggers this issue sometimes.

when switch the focus from edit-tab to output-tab, I get tones of the log messages

This may be a loop in the logger: updating the Output channel triggers something that logs, which then updates the Output channel, and so on…

Please try setting your vscode-neovim log-level to “error” (instead of “debug”/“info”/etc).

Proposal

  1. There is a BufModifiedSet autocmd that calls VSCodeExtensionNotify. We can probably fix that particular case easily.
  2. General fix: any code that updates the Output channel should be wrapped in a function that skips writing to the Output channel if the last ~3 messages looks like a duplicate of the current message.

I’m getting this, too. Before the update it happened once in a while with a stuck “syncing editors”, now after the update it’s happening so often I now have to disable the extension.

The OptionSet problem is gone.

But vscode-neovim still get stuck.

I noticed: when switch the focus from edit-tab to output-tab, I get tones of the log messages below. But since I’m getting stuck a lot without leaving the edit-tab, this is IMO unrelated.

Executing:                                                                                                                                                                                                                       [160/46127]
autocommand <Lua 86: ~/.vscode/extensions/asvetliakov.vscode-neovim-1.18.13/runtime/lua/vscode/internal.lua:307>
                                                                                                                      
                                                           
calling VSCodeExtensionNotify('BufModifiedSet', {'buf': 3, 'modified': v:true})                                                                                                                                                             
                                                                                                                      
line 1:     call rpcnotify(g:vscode_channel, 'vscode-neovim', a:cmd, a:000)                                           
                                                                                                                      
VSCodeExtensionNotify returning #0                                                                                    
                                                                                                                      
continuing in BufModifiedSet Autocommands for "<buffer=3>"                                                            
                                                                                                                      
Executing BufModifiedSet Autocommands for "<buffer=3>"                                                                
autocommand <Lua 86: ~/.vscode/extensions/asvetliakov.vscode-neovim-1.18.13/runtime/lua/vscode/internal.lua:307>      
                                                                                                                      

calling VSCodeExtensionNotify('BufModifiedSet', {'buf': 3, 'modified': v:true})
                                                                                                                      
line 1:     call rpcnotify(g:vscode_channel, 'vscode-neovim', a:cmd, a:000)
                                                                                                                      
VSCodeExtensionNotify returning #0                         
                                                                                                                      
continuing in BufModifiedSet Autocommands for "<buffer=3>"

vscode-neovim 1.18.13 includes an attempted fix for this issue. Please restart vscode and confirm that you are running vscode-neovim 1.18.13 , then report here if there is any improvement.

Thanks to @aFreimuthQby for providing useful logs! https://github.com/vscode-neovim/vscode-neovim/pull/2282 should address this issue. We can keep https://github.com/vscode-neovim/vscode-neovim/issues/2184 open to track the lower-level question about how/why vscode-neovim might be sending malformed RPC messages to node-client.

a solution was already proposed: https://github.com/vscode-neovim/vscode-neovim/issues/2267#issuecomment-2381694486

now waiting on someone to implement it. the extra reports aren’t helping.

In VSCode, identical option settings do not trigger change events, so they won’t cause loops. When writing this part of the logic earlier, I intentionally simplified it by skipping the checks

Even so, these functions should bail (and log a one-time warning) if they notice they’r going in a loop, regardless of the cause.

Fwiw you can run “restart neovim” without reloading the window – that should save you some hassle.

I will say I’ve also experienced this issue on windows 10 WSL…

I am not an LUA developer, so tell me what I can do to help.

I just investigated further, and discovered, the Loop apparently starts as soon as I enter insert mode, stops when I leave it.

It also appears to be unrelated to getting stuck.

When I activating an Editor Tab I find errors like this in ‘exthost.log’:

2024-10-02 10:01:10.390 [error] Error: Illegal value for line at f.t (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:160:1038) at Object.lineAt (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:160:90) at b (/home/af/.vscode/extensions/asvetliakov.vscode-neovim-1.18.12/dist/extension.js:2:187021) at D.<anonymous> (/home/af/.vscode/extensions/asvetliakov.vscode-neovim-1.18.12/dist/extension.js:2:352270) at Generator.next (<anonymous>) at s (/home/af/.vscode/extensions/asvetliakov.vscode-neovim-1.18.12/dist/extension.js:2:350548) 2024-10-02 10:01:27.358 [error] Error: Illegal value for line at f.t (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:160:1038) at Object.lineAt (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:160:90) at b (/home/af/.vscode/extensions/asvetliakov.vscode-neovim-1.18.12/dist/extension.js:2:187021) at D.<anonymous> (/home/af/.vscode/extensions/asvetliakov.vscode-neovim-1.18.12/dist/extension.js:2:352270) at Generator.next (<anonymous>) at s (/home/af/.vscode/extensions/asvetliakov.vscode-neovim-1.18.12/dist/extension.js:2:350548) at runNextTicks (node:internal/process/task_queues:60:5) at process.processTimers (node:internal/timers:511:9)

The last 4 times when I was stuck I had this messages in the ‘exthost.log’:

2024-10-02 10:05:16.668 [error] TypeError: expected msgpack result to be array at /home/af/.vscode/extensions/asvetliakov.vscode-neovim-1.18.12/dist/extension.js:2:161324 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Some times when I am stuck I see the "Syncing

My init.vim looks like this:

set nocompatible
set verbose=16

set ruler number
set title

set showcmd
set termguicolors
set hlsearch

" Use tabs for indent
set tabstop=4 shiftwidth=4 softtabstop=0 noexpandtab
set autoindent smartindent

set autoread

" Display tabs an trailing spaces
set list listchars=tab:•\ ,trail:‡

" Color
syntax on
colorscheme desert
highlight SpellBad ctermbg=Black ctermfg=DarkRed cterm=undercurl
highlight SpellCap ctermbg=Black ctermfg=DarkBlue cterm=undercurl

highlight WhiteSpaceError term=bold ctermfg=Red
match WhiteSpaceError "\s\+$\| \+\ze\t\|[^\t\"]\t\+"

" Enable CursorLine
set cursorline
"highlight clear CursorLine
highlight CursorLine ctermbg=233

Edit: Most of the times when I am stuck I see: “Syncing layout: Syncing active editor”, but not always.

In VSCode, identical option settings do not trigger change events, so they won’t cause loops. When writing this part of the logic earlier, I intentionally simplified it by skipping the checks. I recommend debugging first to identify under what conditions the options are being modified frequently. Typically, many people prefer to disable relative line numbers in insert mode and enable them in other modes.