Is there anyway to use server actions to provide language client connections? #606
Replies: 5 comments
-
Hi @alissa-tung I have no experience with React Server Functions, so I can't give any recommendation there. For the distributed case (=client and server in a different environment) we use |
Beta Was this translation helpful? Give feedback.
-
Thank you, I will read something about those libraries. My intuitions are
|
Beta Was this translation helpful? Give feedback.
-
Generally,
The language server is something isolated and not so much a "server" (the naming is unfortunately misleading), but more an input/output processor. you should always see this as a seperate part from your regular server. Don't know if you are aware that a language server can run in a web worker (client side), but this is only helpful if your language server can run in a browser environment. |
Beta Was this translation helpful? Give feedback.
-
Thank you for responding. We are working around a special language server, where there are many aggregation operations using the code of language client, so the performance is not good like other (CPP, Java, Python), as they only needs to call code action, completion and so on. But in our case there are many aggregations. It is not convenient to move them to lsp custom request/notification for now. As for the safety part, when the language server receives invalid request it will crash directly, which can lose state on the current lsp server process, although make every connections is auth can solve this problem, but we are trying to keep a public playground for unlogined users. And existed custom notification/requests can execute any code. (anyway, we had built a bwrap wrapper for now) |
Beta Was this translation helpful? Give feedback.
-
I realized this is not an issue, maybe we can move to discussion page. So close it for now |
Beta Was this translation helpful? Give feedback.
-
In recent versions of React allowed some functions to run on server side runtime (for example, node), and pass the result of calling such functions to client side runtime (browser)
A common language server program can be called by using NodeJS
child_process
spawn, where the return value of suchspawn
have two propertiesstdin
andstdout
.stdin and stdout can be turns in to
StreamMessageReader
andStreamMessageWriter
fromvscode-jsonrpc/node
, the pair of them isMessageTransport
the key of Message reader and writer is the
read
andwrite
function, that is, consider the following caseif we had already created StreamMessageReader and StreamMessageWriter on server side, export the write and read function as async server actions, then in the client side we declare two new class, use the exported server actions to define the methods
and
but directly wrap the server actions is not okay, since server actions can not have a client function as argument.
So can we use a API which is not like
listen
(which takes a callback) , or can we have some methods to fix the server actions?Beta Was this translation helpful? Give feedback.
All reactions