neoclide / coc-prettier

Prettier extension for coc.nvim.
MIT License
546 stars 48 forks source link

Vim freezing on write: How can I debug? Anyone else getting this? #121

Closed tony closed 2 years ago

tony commented 3 years ago

Potentially related: #74, https://github.com/neoclide/coc.nvim/issues/2148, https://github.com/neoclide/coc.nvim/issues/661

This is coc-prettier, but I have no reliable way to reproduce this. I want to keep the line of communication open on how to collect better diagnostics / see if anyone else has this issue.

In the above issues, its referred to as delays. For me, the client seems to outright freeze. I can't open prompt or navigate around.

How do I find what's hanging VIM up? What types of scripts hang up input in vim? Are there any keyboard commands that could break out of a jam like this?

killall -9 node frees it.

The issue is, this happens after 15 or 20 minutes of editing, enough for me to forget the earlier steps to recreate. If anyone has had similar issues and has workarounds/debug methods to provide more info please do!

chemzqm commented 3 years ago

You can disable formatOnSave for that filetype or use :noa w to write the file.

tony commented 3 years ago

@chemzqm Hey, thank you

And if I wanted to invoke the formatter manually, how would that happen?

Additionally: Are there any commands I can use to help log vim / coc for any errors/messages? If there were instructions for that I could provide more information.

chemzqm commented 3 years ago

I don't think they can help, it mostly issue with your prettier, you can debug it https://github.com/neoclide/coc.nvim/wiki/Debug-coc.nvim

tony commented 3 years ago

After 60 seconds of vim being frozen, I finally saw this:

Error on request (CocAutocmd): request CocAutocmd ['BufWritePre', 2] timeout after 60s

image

vim version: VIM - Vi IMproved 8.2 8022815
node version: v12.20.1
coc.nvim version: 0.0.80-825a54d780
coc.nvim directory: /home/t/.dot-config/.vim/plugged/coc.nvim
term: dumb
platform: linux

https://github.com/tony/vim-config-framework/blob/bc104bf/plugins.vim#L63-L106 https://github.com/tony/vim-config-framework/blob/bc104bf/coc-settings.json

:CocInfo

2021-06-02T14:27:25.377 INFO (pid:32319) [services] - registered service "languageserver.golang"
2021-06-02T14:27:25.378 INFO (pid:32319) [services] - registered service "languageserver.cquery"
2021-06-02T14:27:25.407 INFO (pid:32319) [services] - registered service "json"
2021-06-02T14:27:25.407 INFO (pid:32319) [services] - Json language server state change: stopped => starting
2021-06-02T14:27:25.485 INFO (pid:32319) [plugin] - coc.nvim 0.0.80-825a54d780 initialized with node: v12.20.1 after 151ms
2021-06-02T14:27:25.489 INFO (pid:32319) [language-client-index] - json started with 32531
2021-06-02T14:27:25.538 INFO (pid:32319) [services] - Json language server state change: starting => running
2021-06-02T14:27:25.541 INFO (pid:32319) [services] - service json started
2021-06-02T14:27:26.092 INFO (pid:32319) [watchman] - watchman watching project: /home/t/work/javascript/ckeditor5/packages/ckeditor5-media-embed
2021-06-02T14:28:14.477 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:28:16.542 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:28:22.573 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:28:25.566 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:28:27.677 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:28:33.534 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:28:35.125 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:28:41.229 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:28:48.861 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:28:55.198 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:29:03.506 INFO (pid:32319) [completion-complete] - Results from: json
2021-06-02T14:29:03.683 INFO (pid:32319) [completion-complete] - Results from: json
2021-06-02T14:29:03.937 INFO (pid:32319) [completion-complete] - Results from: json
2021-06-02T14:29:04.243 INFO (pid:32319) [completion-complete] - Results from: json
2021-06-02T14:29:04.505 INFO (pid:32319) [completion-complete] - Results from: json
2021-06-02T14:29:04.865 INFO (pid:32319) [completion-complete] - Results from: json
2021-06-02T14:29:09.350 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:29:11.901 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:29:13.294 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:29:22.566 INFO (pid:32319) [completion-complete] - Results from: json
2021-06-02T14:29:23.551 INFO (pid:32319) [completion-complete] - Results from: json
2021-06-02T14:29:23.960 INFO (pid:32319) [completion-complete] - Results from: json
2021-06-02T14:29:24.427 INFO (pid:32319) [completion-complete] - Results from: json
2021-06-02T14:29:24.721 INFO (pid:32319) [completion-complete] - Results from: json
2021-06-02T14:29:26.828 INFO (pid:32319) [completion-complete] - Results from: json
2021-06-02T14:29:27.877 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:29:33.252 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:29:37.270 INFO (pid:32319) [attach] - receive notification: highlight []
2021-06-02T14:29:45.662 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:29:51.757 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:30:01.126 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:30:05.225 INFO (pid:32319) [attach] - receive notification: highlight []
2021-06-02T14:32:56.213 INFO (pid:32319) [attach] - receive request: CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:32:58.215 WARN (pid:32319) [events] - Handler of BufWritePre blocked more than 2s: Error
    at gq.on (/home/t/.dot-config/.vim/plugged/coc.nvim/build/index.js:132:216)
    at zj.init (/home/t/.dot-config/.vim/plugged/coc.nvim/build/index.js:185:11391)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async qP.init (/home/t/.dot-config/.vim/plugged/coc.nvim/build/index.js:247:10465)
    at async /home/t/.dot-config/.vim/plugged/coc.nvim/build/index.js:129:13510
2021-06-02T14:32:59.216 ERROR (pid:32319) [attach] - Request cost more than 3s CocAutocmd [ 'BufWritePre', 2 ]
2021-06-02T14:34:32.839 INFO (pid:32319) [attach] - receive notification: highlight []
2021-06-02T14:35:42.332 INFO (pid:32319) [attach] - receive notification: openLog []
2021-06-02T14:35:46.220 INFO (pid:32319) [attach] - receive notification: openLog []
tony commented 3 years ago

@chemzqm

Normally in cases like these I choose between killall -9 vim or killall -9 node (depending on whichever is less irritating to lose)

Do the above logs help clue you in on if this is a coc-prettier issue or not? Unfortunately it doesn't specify which coc plugin is impacting things.

Thank you!

chemzqm commented 3 years ago

Should be caused by coc-prettier, try use prettier.disableLanguages configuration.

tony commented 3 years ago

@chemzqm Do you think prettier.disableLanguages works?

I have json disabled and vim still freezes when in json filetypes

i've confimed through set filetype the current buffer's filetype is json

Only other link I see is vscode's prettier plugin: https://github.com/prettier/prettier-vscode/issues/1854

chemzqm commented 3 years ago

I have json disabled and vim still freezes when in json filetypes

Could be caused by other vim plugin.

chemzqm commented 2 years ago

Try profile your vim https://github.com/neoclide/coc.nvim/wiki/F.A.Q#how-could-i-profile-cocnvim