Comments (3)
I tested this in the testbed and requests send from the server to the client are properly resolved. The code is in the dbaeumer/underground-vole-plum
branch in case you want to have a look.
Can you try to test this from the TS server part directly to the client. If that works for you as well (as it does for me) it is more likely with the bridge code.
from vscode-languageserver-node.
Hello,
I tested to perform the sendRequest
inside an handler defined in typescript. Its works correctly.
The problem however is that my bridge code seems to work too.
The rust part of my codebase calls the typescript callback to send a request. I get the first log but never the resolve of catch.
Here is the callback from the code above :
const sendRequest = async (method: string, params: any) => {
connection.console.log(`sendRequeest: ${method} ${JSON.stringify(params)}`); // is logged
try {
let res = await connection.sendRequest(method, params); // my handler is executed during this call
connection.console.log(`sendRequest: ${method} ${JSON.stringify(params)} => ${JSON.stringify(res)}`); // never logged
return res;
} catch (error) {
connection.console.error('Error with sendRequest:', error); // never log too
}
};
I also tried with a "promise" version to see if the async was the problem but I get the same behavior :
const sendRequest = (method: string, params: any): Promise<any> {
return new Promise((resolve, reject) => {
connection.console.log(`sendRequeest: ${method} ${JSON.stringify(params)}`); // is logged
connection.sendRequest(method, params) // my handler is executed during this call
.then((res: any) => {
connection.console.log(`sendRequest: ${method} ${JSON.stringify(params)} => ${JSON.stringify(res)}`); // never logged
resolve(res)
})
.catch((err) => {
connection.console.error('Error with sendRequest:', err); // never logged
reject(err);
});
});
};
Is there any context specific behavior with the Connection
class ?
from vscode-languageserver-node.
I assume that you compile your Rust code to WASM. If this is the case WASM is fully sync and as soon as you execute WASM code the corresponding worker never falls back to the NodeJS event loop until the WASM code is finished (even not if you call code in the JS host). Hence the promise can never be fullfilled.
To get something like this working you either need to asyncify the WASM code, wait for async support in WASM or use another worker and SharedArrayBuffers with Atomics to do the promise handling in yet another worker. You might want to look at code here to see how this can be done: https://github.com/microsoft/vscode-wasi.git
I will close the issue since there is nothing in the LSP library I can do about this. The above repository contains an example on how to implement a LSP server in Rust, compile it to WASM and then use without any TS clue code. See https://github.com/microsoft/vscode-wasi/blob/dbaeumer/mere-meerkat-green/testbeds/lsp-rust/client/src/extension.ts#L37
from vscode-languageserver-node.
Related Issues (20)
- notebook cell doesn't get document highlight request HOT 4
- problem with priority of onCompletion items HOT 2
- Support for Generators using LSP HOT 6
- Progress percentage should be an uint according to the spec HOT 1
- Fix ProtocolConverter#asWorkspaceEdit to correctly support workspace edits with snippets HOT 2
- New named structs in metamodel should maybe not be "proposed"? HOT 8
- `NotebookCell` is missing `outputs` field HOT 15
- Extend predefined semantic token types to include `label` HOT 1
- Fix CancellationReceiverStrategy type definition to include RequestCancellationReceiverStrategy HOT 1
- changelog?
- Expected sequence of events for an initialization failure HOT 2
- LanguageClient adds an extra `--stdio` argument when using `TransportKind.stdio` HOT 1
- Error compiling test-provider-sample executionCount does not exist on type StatementCoverage
- Kobicoin HOT 2
- LSP request failure toasts cannot be turned off HOT 9
- Missing `onSemanticTokens` method on `Connection` HOT 2
- Semantic tokens that are not in ascending order will not be highlighted HOT 7
- Document symbols in editor do not show after starting VSCode with file open HOT 8
- Two-part Hover info using `MarkupContent` HOT 3
- Language server is not started until a file is opened HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-languageserver-node.