vim-denops / denops.vim

🐜 An ecosystem of Vim/Neovim which allows developers to write cross-platform plugins in Deno

Home Page:https://vim-denops.github.io/denops-documentation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What will happen if both client and server starts a rpc-request at the same time ?

skywind3000 opened this issue · comments

I am reading the vim rpc implementation:

function! denops#_internal#rpc#vim#request(chan, method, params) abort
let [l:ok, l:err] = ch_evalexpr(a:chan, [a:method] + a:params)
if l:err isnot# v:null
throw l:err
endif
return l:ok
endfunction

The function ch_evalexpr will send a request to the server and wait for a response. However, the TCP socket is a bi-directional channel. If the server sends a request or a notification at the same time, ch_evalexpr will not receive the correct response but instead a new request/notification from the server.

And the code using denops#_internal#rpc#vim#request will get an unexpected return value.

This is likely to happen when the server and client are sending notifications/requests to each other frequently or when the server is busy.

Another potential issue may occur due to nested RPC calls from both sides:

1) client is requesting a server function
2) in that server function, it will request another client-side function.
3) the client is still waiting for the response from the server-side, but it will only receive a new rpc-request.

Sorry for late reply.

Well, unfortunately we don't have clear answer for your question because we just use Vim's RPC implementation and we don't have deep knowledge about that.

However, denops works well for several years in many environments and we haven't heard about message mixed issues except on Neovim (that's solved already) so we think Vim properly handle such case.

Is this question comes from actual issues or just from code investigation?