-
-
Notifications
You must be signed in to change notification settings - Fork 959
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
What will happen if both client and server starts a rpc-request at the same time ? #4756
Comments
The request response and notification from server side have different ID number with JSON encoded text, so vim should be able to distinguish them correctly.
It could work most of the time, unless the client-side function sends a request to the server again.
Avoid invoke |
Unfortunately, vim can't handle request ID correctly in step1: https://github.com/vim/vim/blob/6ffcc58be32aa1b337bc839cfe173b68cfde7085/src/channel.c#L5210-L5213 step2: https://github.com/vim/vim/blob/6ffcc58be32aa1b337bc839cfe173b68cfde7085/src/channel.c#L4546-L4550 In the https://github.com/vim/vim/blob/6ffcc58be32aa1b337bc839cfe173b68cfde7085/src/channel.c#L2478-L2495 There may be an "order problem": 1) client sends an request with id = 100; The server would have no chance to handle msg 100 because it is still waiting for the response of 200, while the client is waiting for the response of 100 and can’t do anything about msg 200. |
I am reading the vim rpc implementation:
coc.nvim/autoload/coc/client.vim
Lines 175 to 182 in eb63f77
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
coc#rpc#request(method, args)
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.
Sometimes, CoC becomes unresponsive in Vim on some low-end Windows machines, particularly within the first 5 seconds after opening a new file. If I input too much, CoC may freeze my gVim.
Is it possible that it is caused by this problem ?
The text was updated successfully, but these errors were encountered: