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

CocRestart fails #4843

Closed
laoshaw opened this issue Dec 29, 2023 · 7 comments · Fixed by #4868
Closed

CocRestart fails #4843

laoshaw opened this issue Dec 29, 2023 · 7 comments · Fixed by #4868

Comments

@laoshaw
Copy link

laoshaw commented Dec 29, 2023

Result from CocInfo

versions

vim version: VIM - Vi IMproved 9.0 9000749
node version: v18.17.1
coc.nvim version: 0.0.82-d1568d56 2023-09-29 19:43:34 +0800
coc.nvim directory: /home/tester/.vim/plugged/coc.nvim
term: dumb
platform: linux

Log of coc.nvim

2023-12-29T14:02:11.403 INFO (pid:7888) [configurations] - Add folder configuration from cwd: /home/tester/devel///SDK/.vim/coc-settings.json
2023-12-29T14:02:11.649 WARN (pid:7888) [commands] - Command prettier.createConfigFile already registered
2023-12-29T14:02:11.649 WARN (pid:7888) [commands] - Command prettier.openOutput already registered
2023-12-29T14:02:11.649 WARN (pid:7888) [commands] - Command prettier.forceFormatDocument already registered
2023-12-29T14:02:11.649 WARN (pid:7888) [commands] - Command prettier.formatFile already registered
2023-12-29T14:02:11.689 INFO (pid:7888) [plugin] - coc.nvim initialized with node: v18.17.1 after 321
2023-12-29T14:02:11.701 INFO (pid:7888) [services] - LanguageClient clangd state change: stopped => starting
2023-12-29T14:02:11.707 INFO (pid:7888) [language-client-index] - Language server "clangd" started with 7900
2023-12-29T14:02:11.717 INFO (pid:7888) [services] - LanguageClient clangd state change: starting => running
2023-12-29T14:02:11.721 INFO (pid:7888) [services] - service clangd started
2023-12-29T14:02:11.739 INFO (pid:7888) [core-watchman] - watchman watching project: /home/tester/devel///SDK
2023-12-29T14:03:11.103 INFO (pid:7888) [attach] - receive notification: showInfo []                                           

Describe the bug

:CocStart shows below

image

Reproduce the bug

We will close your issue when you don't provide minimal vimrc and we can't
reproduce it

  • Create file mini.vim with:

    set nocompatible
    set runtimepath^=/path/to/coc.nvim
    filetype plugin indent on
    syntax on
    set hidden
  • Start (neo)vim with command: vim -u mini.vim

  • Operate vim.
    same result:
    image

Screenshots (optional)

If applicable, add screenshots to help explain your problem.

@laoshaw
Copy link
Author

laoshaw commented Dec 29, 2023

:CocStart did not show error messages though

@fannheyward
Copy link
Member

fannheyward commented Jan 3, 2024

#4850 fixed the g:coc_status issue.

The abnormal exit reproduced with vim, couldn't with nvim.

@laoshaw
Copy link
Author

laoshaw commented Jan 3, 2024

image
After I did 'PlugUpdate' and 'CocUpdate', 'CocRestart' still gave me above message with vim9.

@cridemichel
Copy link
Contributor

same behavior here

## versions

vim version: VIM - Vi IMproved 9.1 9010000
node version: v21.6.0
coc.nvim version: 0.0.82-d1568d56 2023-09-29 19:43:34 +0800
coc.nvim directory: /Users/demichel/.vim/plugged/coc.nvim
term: iTerm.app
platform: darwin

## Log of coc.nvim

2024-01-19T09:06:48.263 WARN (pid:43471) [workspace] - Extension "coc-lists" registered synchronized autocmd "VimLeavePre", which could be slow.
2024-01-19T09:06:48.298 INFO (pid:43471) [plugin] - coc.nvim initialized with node: v21.6.0 after 272
2024-01-19T09:06:51.245 INFO (pid:43471) [attach] - receive notification: showInfo []

@cridemichel
Copy link
Contributor

cridemichel commented Jan 19, 2024

#4850 fixed the g:coc_status issue.

The abnormal exit reproduced with vim, couldn't with nvim.

Hi,
by invoking CocRestart the function coc#client#stop defined in autoload/coc/client.vim is called.
This function terminates the coc client through the vim function job_stop() or neovim function jobstop().
Probably, with neovim the error message couldn't be reproduced since, according to its manual (see h:job_control.txt):

*on_exit*
Arguments passed to on_exit callback:
  0: |job-id|
  1: Exit-code of the process, or 128+SIGNUM if by signal (e.g. 143 on SIGTERM).
  2: Event type: "exit"

so that if exit code of the process is -1, 143 (SIGTERM) is passed as argument of the on_exit callback,
since jobstop() sends a SIGTERM signal.
Differently, vim, according to the manual (see h:channel.txt) passes to the "exit_cb" callback the exit code of the process, which is -1.
Maybe one should ignore a process exit code equal to -1, not issuing any error message?

my two cents
best C.

@cridemichel
Copy link
Contributor

cridemichel commented Jan 23, 2024

Hi,
I noticed that if server is stopped by closing channel connections, the abnormal exit does not occurr anymore. In other words, consider the function "coc#rpc#restart()", which is in autoload/coc/rpc.vim, i.e.

function! coc#rpc#restart()
  if empty(s:client)
    call coc#rpc#start_server()
  else
    call coc#highlight#clear_all()
    call coc#ui#sign_unplace()
    call coc#float#close_all()
    autocmd! coc_dynamic_autocmd
    autocmd! coc_dynamic_content
    autocmd! coc_dynamic_option
    call coc#rpc#request('detach', [])
    unlet g:coc_status
    let g:coc_service_initialized = 0
    sleep 100m
    if exists('$COC_NVIM_REMOTE_ADDRESS')
      call coc#rpc#close_connection()
      sleep 100m
      call coc#rpc#start_server()
    else
      let s:client['command'] = coc#util#job_command()
      call coc#client#restart(s:name)
      call s:check_vim_enter()
    endif
    echohl MoreMsg | echom 'starting coc.nvim service' | echohl None
  endif
endfunction

if server is stoped by closing connections, i.e. the function is modified as follows:

function! coc#rpc#restart()
  if empty(s:client)
    call coc#rpc#start_server()
  else
    call coc#highlight#clear_all()
    call coc#ui#sign_unplace()
    call coc#float#close_all()
    autocmd! coc_dynamic_autocmd
    autocmd! coc_dynamic_content
    autocmd! coc_dynamic_option
    call coc#rpc#request('detach', [])
    unlet g:coc_status
    let g:coc_service_initialized = 0
    sleep 100m
    if 1 "exists('$COC_NVIM_REMOTE_ADDRESS') by doing this connections are closed and server started
      call coc#rpc#close_connection()
      sleep 100m
      call coc#rpc#start_server()
    else
      let s:client['command'] = coc#util#job_command()
      call coc#client#restart(s:name)
      call s:check_vim_enter()
    endif
    echohl MoreMsg | echom 'starting coc.nvim service' | echohl None
  endif
endfunction

the abnormal exit does not occurr anymore. I also noticed that COC_NVIM_REMOTE_ADDRESS variable is not set,
maybe is this the real culprit of the abnormal exit?
HTH

best C.

@Lmills71
Copy link

😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants