Coc.nvim: neovim freezes upon file write (save)

Created on 23 Jul 2019  Â·  8Comments  Â·  Source: neoclide/coc.nvim

Result from CocInfo

## versions                                                                                                                                                    

vim version: NVIM v0.3.7
node version: v11.0.0
coc.nvim version: 0.0.73-56825890dc
term: screen-256color
platform: linux

## Messages
E325: ATTENTION
## Output channel: snippets

[Info  - 2:54:11 PM] watchman watching project: /home/user/.config/coc/ultisnips
[Info  - 2:54:11 PM] subscribing "**/*.snippets" in /home/user/.config/coc/ultisnips

Describe the bug

neovim vim freezes after I save a file. It's not 100% reliable, sometimes I have to edit file for a while. Maybe the following line from strace log has anything to do with that:

write(16, "\224\0\2\252CocAutocmd\222\253BufWritePre\1", 28) = 28

I've tried coc from source, from release branch and from tags, it's the same everywhere. It surfaced very recently, but weirdly using the latest tag does not help. I'm not sure how to trace it further...

strace output when nvim has frozen

futex(0x7f4652bfee48, FUTEX_WAKE_PRIVATE, 1) = 1
stat("/home/user/TODO.txt", {st_mode=S_IFREG|0664, st_size=460316, ...}) = 0
access("/home/user/TODO.txt", W_OK) = 0
stat("/home/user/TODO.txt", {st_mode=S_IFREG|0664, st_size=460316, ...}) = 0
epoll_wait(9, [], 1024, 0)              = 0
epoll_wait(9, [], 1024, 0)              = 0
write(16, "\224\0\2\252CocAutocmd\222\253BufWritePre\1", 28) = 28
epoll_wait(9, [], 1024, 0)              = 0
epoll_wait(9, [{EPOLLIN, {u32=12, u64=12}}], 1024, -1) = 1
read(12, "\1\0\0\0\0\0\0\0", 1024)      = 8
futex(0x7f4651c263ac, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x7f4651c263a8, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
futex(0x7f4651c26380, FUTEX_WAKE_PRIVATE, 1) = 1
epoll_wait(9, [{EPOLLIN, {u32=12, u64=12}}], 1024, -1) = 1
read(12, "\1\0\0\0\0\0\0\0", 1024)      = 8
futex(0x7f4651c263ac, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x7f4651c263a8, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
futex(0x7f4651c26380, FUTEX_WAKE_PRIVATE, 1) = 1
epoll_wait(9,

Reproduce the bug

  • Create file mini.vim with:
set rtp+=~/.fzf
set nocompatible
call plug#begin('~/.vim/plugged')

"Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/coc.nvim', {'tag': '*', 'branch': 'release'}
"Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}

call plug#end()
filetype plugin indent on
syntax enable
set nocompatible
set laststatus=2
set encoding=utf-8
set fileencodings=utf-8,cp1251,koi8-r,cp866
set showcmd
colorscheme desert
set termguicolors
  • Start (neo)vim with command: vim -u mini.vim
  • Operate vim, add contents to the file
  • Save the file with <Esc>w:<Enter>

Coc debug log

2019-07-23T14:18:39.800 INFO (pid:1823) [plugin] - coc 0.0.73-56825890dc initialized with node: v11.0.0
2019-07-23T14:18:39.827 INFO (pid:1823) [watchman] - watchman watching project: /home/user/.config/coc/ultisnips
2019-07-23T14:19:00.845 INFO (pid:1823) [completion-complete] - Results from: around
2019-07-23T14:19:03.742 INFO (pid:1823) [willSaveHandler] - Will save cost: 88
2019-07-23T14:19:08.388 INFO (pid:1823) [completion-complete] - Results from: around
2019-07-23T14:19:11.857 INFO (pid:1823) [willSaveHandler] - Will save cost: 87
2019-07-23T14:19:15.551 INFO (pid:1823) [completion-complete] - Results from: around
2019-07-23T14:19:18.388 INFO (pid:1823) [willSaveHandler] - Will save cost: 99
2019-07-23T14:20:55.954 INFO (pid:1823) [completion-complete] - Results from: around
2019-07-23T14:20:58.093 INFO (pid:1823) [willSaveHandler] - Will save cost: 94
2019-07-23T14:31:37.719 INFO (pid:1823) [completion-complete] - Results from: around
2019-07-23T14:31:41.838 INFO (pid:1823) [willSaveHandler] - Will save cost: 89
2019-07-23T14:31:56.703 INFO (pid:1823) [completion-complete] - Results from: around
2019-07-23T14:31:58.830 INFO (pid:1823) [willSaveHandler] - Will save cost: 90
2019-07-23T14:44:12.994 INFO (pid:1823) [completion-complete] - Results from: around

Most helpful comment

node version: v11.0.0

You should upgrade your node, 11.0.0 is buggy.

All 8 comments

node version: v11.0.0

You should upgrade your node, 11.0.0 is buggy.

I have this problem with node 13.7.0 in a file with long lines

@theonlygusti can't reproduce, try use "coc.preferences.formatOnSaveFiletypes": [] in your config file.

Yes, node was the culprit, I had recently downgraded to 11, had to use: nvm alias default 14.0.0 to set the default to a newer version of node, if you use nvm set 14.0.0 that only applies to the current session, when you start a new session that is forgotten, have to set the default to the version you want to use each time you open the terminal.

I have node v14.3.0, but still have this problem.

In a json file with 2000 lines and over 1000 'columns', :wq takes well over five minutes to write and quit.

Same experience as theonlygusti. v14.3.0
Takes a very long time to save files.

I can't reproduce.

I am also facing this issue. I often have a buffer with a large tsv file open in the background (>30000 lines with 10 columns). If I now save the python file that I am actually editing, vim tends to freeze for varying amounts of time (not always though). Firing up htop shows coc.nvim/build/index.js at 100% CPU usage.

Funny enough, this only seems to be the case after I have spent some time editing with said tsv file open in the background. If I start a new vim instance with both files open, saving will work without delay.

vim version: VIM - Vi IMproved 8.2 8021704
node version: v14.12.0
coc.nvim version: 0.0.79-b1288b0de4
Was this page helpful?
0 / 5 - 0 ratings

Related issues

npearson72 picture npearson72  Â·  3Comments

andys8 picture andys8  Â·  3Comments

chemzqm picture chemzqm  Â·  3Comments

lanox picture lanox  Â·  3Comments

czepluch picture czepluch  Â·  3Comments