weirongxu / coc-explorer

📁 Explorer for coc.nvim
MIT License
1.14k stars 45 forks source link

[BUG] Invalid buffer id: [id] #527

Closed Nodman closed 2 years ago

Nodman commented 2 years ago

Describe the bug

Sometimes coc-explorer won't open (with floating preset) and throws error: [coc.nvim] Error: Vim(call):E5555: API call: Invalid buffer id: [bufferId]. Switching to any other buffer and trying to open coc-exploer will yield same error with same bufferId. However :CocCommand explorer will work as expected, but :CocCommand explorer --preset floating will still produce same error with same id. So it looks like it has something to do either with floating behaviour or with my preset specifically. This happens rather randomly but pretty often.

Result from CocInfo

>> click to expand << ``` ## versions vim version: NVIM v0.7.0 node version: v16.15.0 coc.nvim version: 0.0.80-032044b1 2022-05-23 03:12:28 +0800 coc.nvim directory: /$HOME/.local/share/nvim/site/pack/packer/start/coc.nvim term: tmux platform: darwin ## Log of coc.nvim 2022-05-23T16:07:10.140 INFO (pid:9784) [configurations] - Add folder configuration from cwd: /Users/user/repo/.vim/coc-settings.json 2022-05-23T16:07:10.141 INFO (pid:9784) [configurations] - Change folder configuration from cwd to: /Users/user/repo/.vim/coc-settings.json 2022-05-23T16:07:10.216 INFO (pid:9784) [services] - registered service "languageserver.bash" 2022-05-23T16:07:10.216 INFO (pid:9784) [services] - registered service "languageserver.flow" 2022-05-23T16:07:10.308 INFO (pid:9784) [services] - registered service "stylelintplus" 2022-05-23T16:07:10.311 INFO (pid:9784) [plugin] - coc.nvim initialized with node: v16.15.0 after 133ms 2022-05-23T16:07:11.167 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 4 ] 2022-05-23T16:07:11.167 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 4 ] 2022-05-23T16:07:14.199 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 8 ] 2022-05-23T16:07:14.200 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 8 ] 2022-05-23T16:07:14.200 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 9 ] 2022-05-23T16:07:14.200 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 9 ] 2022-05-23T16:07:14.201 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 10 ] 2022-05-23T16:07:14.202 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 10 ] 2022-05-23T16:07:14.202 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 11 ] 2022-05-23T16:07:14.202 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 11 ] 2022-05-23T16:07:14.203 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 3 ] 2022-05-23T16:07:14.203 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 3 ] 2022-05-23T16:07:14.204 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 2 ] 2022-05-23T16:07:14.204 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 2 ] 2022-05-23T16:07:14.204 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 7 ] 2022-05-23T16:07:14.204 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 7 ] 2022-05-23T16:07:14.205 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 5 ] 2022-05-23T16:07:14.205 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 5 ] 2022-05-23T16:07:14.206 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 6 ] 2022-05-23T16:07:14.206 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 6 ] 2022-05-23T16:07:14.207 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufDelete', 1 ] 2022-05-23T16:07:14.207 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufDelete', 1 ] 2022-05-23T16:07:14.207 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 1 ] 2022-05-23T16:07:14.207 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 1 ] 2022-05-23T16:07:14.246 INFO (pid:9784) [services] - flow state change: stopped => starting 2022-05-23T16:07:14.248 INFO (pid:9784) [services] - registered service "eslint" 2022-05-23T16:07:14.248 INFO (pid:9784) [services] - ESLint state change: stopped => starting 2022-05-23T16:07:14.266 INFO (pid:9784) [services] - registered service "tsserver" 2022-05-23T16:07:14.274 INFO (pid:9784) [language-client-index] - Language server "languageserver.flow" started with 9873 2022-05-23T16:07:14.672 INFO (pid:9784) [services] - flow state change: starting => running 2022-05-23T16:07:14.674 INFO (pid:9784) [services] - service languageserver.flow started 2022-05-23T16:07:14.778 INFO (pid:9784) [services] - ESLint state change: starting => running 2022-05-23T16:07:14.779 INFO (pid:9784) [services] - service eslint started 2022-05-23T16:07:26.939 INFO (pid:9784) [attach] - receive notification: jumpDefinition [] 2022-05-23T16:07:35.207 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 24 ] 2022-05-23T16:07:35.207 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 24 ] 2022-05-23T16:07:35.987 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 28 ] 2022-05-23T16:07:35.987 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 28 ] 2022-05-23T16:07:35.988 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 29 ] 2022-05-23T16:07:35.988 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 29 ] 2022-05-23T16:07:35.988 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 23 ] 2022-05-23T16:07:35.989 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 23 ] 2022-05-23T16:07:35.989 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 22 ] 2022-05-23T16:07:35.989 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 22 ] 2022-05-23T16:07:35.989 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 27 ] 2022-05-23T16:07:35.989 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 27 ] 2022-05-23T16:07:35.990 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 25 ] 2022-05-23T16:07:35.990 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 25 ] 2022-05-23T16:07:35.990 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 26 ] 2022-05-23T16:07:35.991 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 26 ] 2022-05-23T16:07:37.255 INFO (pid:9784) [attach] - receive notification: runCommand [ 'explorer', '--preset', 'floating', '--sources', 'file+' ] 2022-05-23T16:07:38.204 INFO (pid:9784) [attach] - Request action: doKeymap [ 'explorer-key-n-[cr]' ] 2022-05-23T16:08:09.782 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufDelete', 33 ] 2022-05-23T16:08:09.783 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufDelete', 33 ] 2022-05-23T16:08:09.795 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufDelete', 33 ] 2022-05-23T16:08:09.795 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufDelete', 33 ] 2022-05-23T16:08:12.742 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 31 ] 2022-05-23T16:08:12.742 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 31 ] 2022-05-23T16:08:12.743 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufDelete', 32 ] 2022-05-23T16:08:12.743 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufDelete', 32 ] 2022-05-23T16:08:12.743 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 32 ] 2022-05-23T16:08:12.743 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 32 ] 2022-05-23T16:08:12.744 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 33 ] 2022-05-23T16:08:12.744 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 33 ] 2022-05-23T16:13:02.257 INFO (pid:9784) [attach] - receive notification: runCommand [ 'explorer', '--preset', 'floating', '--sources', 'file+' ] 2022-05-23T16:13:02.264 ERROR (pid:9784) [node-client] - request error on "nvim_call_function" [ 'coc_explorer#resume', [ 20, { name: 'floating' }, { width: 70, height: 64, left: 93, top: 0.5, focus: true, border_bufnr: 31, border_enable: true, border_chars: [Array], title: 'coc-explorer' } ] ] Vim(call):E5555: API call: Invalid buffer id: 31 Error at _M.request (/Users/user/.local/share/nvim/site/pack/packer/start/coc.nvim/build/index.js:29:43425) at _M.call (/Users/user/.local/share/nvim/site/pack/packer/start/coc.nvim/build/index.js:34:3815) at tt.resume (/Users/user/.config/coc/extensions/node_modules/coc-explorer/lib/index.js:324:65661) at ks.open (/Users/user/.config/coc/extensions/node_modules/coc-explorer/lib/index.js:324:73834) at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5) 2022-05-23T16:13:04.196 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 35 ] 2022-05-23T16:13:04.197 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 35 ] 2022-05-23T16:13:06.367 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_coc_helper_1', 'BufWipeout', 36 ] 2022-05-23T16:13:06.367 INFO (pid:9784) [attach] - receive notification: runCommand [ 'coc-helper.internal.didVimEvent_m1_v0_13_0_explorer_2', 'BufWipeout', 36 ] 2022-05-23T16:13:06.378 INFO (pid:9784) [attach] - receive notification: showInfo [] ```

Steps to reproduce As I mentioned above, this happens rather randomly, so unfortunately I was not able to get accurate steps to reproduce this. Those are my typical steps when I am getting this error:

  1. execute nvim
  2. open con-explorer with mapped key (<CMD>CocCommand explorer --preset floating --sources file+<CR>)
  3. open any file
  4. repeat step 2 and open another file in split
  5. return to previous buffer window.
  6. repeat step 2
  7. get error

Additional context coc-settings:

  "explorer.keyMappings.global": {
    "<cr>": ["expandable?", ["expanded?", "collapse", "expand"], "open"],
    "v": "open:vsplit",
    "s": "open:split"
  },
  "explorer.file.showHiddenFiles": true,
  "explorer.floating.border.chars": [" ", " ", " ", " ", " ", " ", " ", " "],
  "explorer.buffer.tabOnly": true,
  "explorer.icon.enableNerdfont": true,
  "explorer.buffer.showHiddenBuffers": true,

config:

map(
  'n',
  '<leader>e',
  '<CMD>CocCommand explorer  --preset floating --sources file+<CR>',
  { silent = true, noremap = false }
)

vim.g.coc_global_extensions = {
  'coc-explorer',
  'coc-json',
  'coc-eslint',
  'coc-tsserver',
  'coc-stylelintplus',
  'coc-prettier',
  'coc-lua',
  'coc-snippets',
  'coc-clangd',
}

local fileChildTemplate = {
  '[git | 2]',
  '[selection | clip | 1]',
  '[indent]',
  '[icon | 1] ',
  '[diagnosticError & 1]',
  '[filename omitCenter 1]',
  '[modified]',
  '[readonly]',
  '[linkIcon & 1]',
  '[link growRight 1 omitCenter 5]',
}

vim.g.coc_explorer_global_presets = {
  floating = {
    ['position'] = 'floating',
    ['floating-width'] = 70,
    ['floating-height'] = -1,
    ['file-root-template'] = '[icon] [root]',
    ['file-child-template'] = table.concat(fileChildTemplate),
  },
}

Thank you for your help!

weirongxu commented 2 years ago

Should be fix by https://github.com/weirongxu/coc-explorer/commit/da19f800dfc125ccdd351b486acd45f7e4ebc88d

Nodman commented 2 years ago

Thank you!

Nodman commented 2 years ago

Unfortunately, still getting the same error:

2022-05-26T15:02:01.865 INFO (pid:9557) [attach] - Request action: doAutocmd [ 1, 1 ]
2022-05-26T15:02:17.957 INFO (pid:9557) [attach] - receive notification: jumpDefinition []
2022-05-26T15:02:19.016 INFO (pid:9557) [attach] - receive notification: runCommand [ 'explorer', '--preset', 'floating', '--sources', 'file+' ]
2022-05-26T15:02:19.024 ERROR (pid:9557) [node-client] - request error on "nvim_call_function" [
  'coc_explorer#resume',
  [
    13,
    { name: 'floating' },
    {
      width: 70,
      height: 70,
      left: 105.5,
      top: 0.5,
      focus: true,
      border_bufnr: 12,
      border_enable: true,
      border_chars: [Array],
      title: 'coc-explorer'
    }
  ]
] Vim(call):E5555: API call: Invalid buffer id: 12 Error
    at BM.request (/Users/user/.local/share/nvim/site/pack/packer/start/coc.nvim/build/index.js:29:43425)
    at BM.call (/Users/user/.local/share/nvim/site/pack/packer/start/coc.nvim/build/index.js:34:3815)
    at tt.resume (/Users/user/.config/coc/extensions/node_modules/coc-explorer/lib/index.js:324:65661)
    at ks.open (/Users/user/.config/coc/extensions/node_modules/coc-explorer/lib/index.js:324:73834)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
2022-05-26T15:02:30.446 INFO (pid:9557) [attach] - receive notification: showInfo []