-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[Workspace API] Cannot create/delete file in Theia if another websocket uses 'filesystem' service #8205
Comments
@gorshkov-leonid I'm not quite sure I understand the use-case or the goal, why do you want to interface to internal services from your web-application? I don't think the internals are meant to be interfaced in such a way, these APIs are meant for Theia extensions. Can you perhaps clarify the overall goal of what you are trying to achieve? |
@vince-fugnitto sure, some details are needed |
Ok, so first things first I don't think we really support third parties accessing the websocket endpoints, and if someone does he needs to intimately understand and follow the current state of it. Now regarding your issue: the patch you linked is the culprit indeed. What it does is that it waits for listeners of the (See relevant line) |
@marechal-p thank you for explanation. But I mean there are two clients do not work:
Che works unless test-app connected. And what I cannot I understand, that why when I create file via Eclipse Che, that confirmation is got by test-app? It seems problem is common. But I tried to answer with id received in willCreate (I expected 97 but received 0)
Also, I decided that it could be error and answered with id 97.
This all did not help me |
And I noticed, that my client got
But Che got
That is in the case when creation was called only in Che. Why Eclipse Che got 8 the 9 then 10, but my test-app gots always 0? Neither 0 nor 8 do not work. |
IIUC the first id is for a given ws logical channel (roughly one per service) and the json-rpc id is per request (it increments every time a message is sent). I just tried opening two Theia tabs (emulating two apps hooked on a ws each) and adding files still worked. I'd recommend you to keep looking for differences between the way you handle messaging and how Theia does. |
After looking a bit you might be blocking on this:
|
I can make a conclusion about how It works. If I create file in Eclipse Che that all clients will receive request I think if file is created in one client that there no need to send confirmation by other clients. |
This is normal because you only send one message, so it doesn't need to increment anything. Che/Theia makes a bunch of requests, hence why you see the number increasing. I quickly tried to do what you are trying, and it must be something you are doing wrong when responding, because it works with the following NodeJS snippet (disclaimer: it's ugly) const WebSocket = require('ws')
const ws = new WebSocket('ws://localhost:3000/services')
ws.on('open', () => {
console.log('open')
send(ws, JSON.stringify({
id: 0,
kind: 'open',
path: '/services/filesystem',
}))
})
ws.on('message', recv => {
const parsed = JSON.parse(recv)
console.log(`received: ${recv}`)
switch (parsed.kind) {
case 'ready': {
console.log(`channel #${parsed.id} is ready.`)
send(ws, JSON.stringify({
id: 0,
kind: 'data',
content: JSON.stringify({
id: 0,
jsonrpc: '2.0',
method: 'createFile',
params: 'file:///d%3A/sources/node-pty/src/Untitled.txt'
})
}))
} break
case 'data': {
const sub = JSON.parse(parsed.content)
if ('method' in sub) {
if (sub.method === 'willCreate') {
send(ws, JSON.stringify({
id: 0,
kind: 'data',
content: JSON.stringify({
id: sub.id,
jsonrpc: '2.0',
result: null,
})
}))
}
}
} break
}
})
function send(ws, message) {
console.log(`sent: ${message}`)
ws.send(message)
}
/** Execution logs:
open
sent: {"id":0,"kind":"open","path":"/services/filesystem"}
received: {"kind":"ready","id":0}
channel #0 is ready.
sent: {"id":0,"kind":"data","content":"{\"id\":0,\"jsonrpc\":\"2.0\",\"method\":\"createFile\",\"params\":\"file:///d%3A/sources/node-pty/src/Untitled.txt\"}"}
received: {"kind":"data","id":0,"content":"{\"jsonrpc\":\"2.0\",\"id\":0,\"method\":\"willCreate\",\"params\":\"file:///d%3A/sources/node-pty/src/Untitled.txt\"}"}
sent: {"id":0,"kind":"data","content":"{\"id\":0,\"jsonrpc\":\"2.0\",\"result\":null}"}
received: {"kind":"data","id":0,"content":"{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"didCreate\",\"params\":[\"file:///d%3A/sources/node-pty/src/Untitled.txt\",false]}"}
*/ When I don't respond to the incoming
cc @akosyakov, I don't have an opinion here. |
@marechal-p Thank you for example ⭐ I made some wrong conclusions because of invalid requests (mixed up a path to project). Id is incremented as expected. Eclipse Che always accepts As a result, as you say, all work 👌 : But it is not intuitively clear that creation and deletion should be approved by all clients. I have no questions more - It is an internal design and I will use it at our own risk. |
it's fixed in #7908, but there is no |
I integrate my web application with Eclipse Che to get/create/update/delete content through websocket connection. I use "/services" websocket and "filesystem" service in the way as Eclipse Che does it. This way worked in Eclipse Che 7.7.0, but does not work properly in 7.15.0
When my socket is connected then I cannot create and delete files in Eclipse Che. Although a read and update work. A new socket somehow affects the functionality of Eclipse Che.
I thought that problem is in Eclipse Che(see eclipse-che/che#17443), but found out that it is reproduced on Theia.
I wrote test-client to demonstrate the problem:
test.zip
Theia version
OS
Steps to reproduce
docker run -it -p 3000:3000 -v "<path>:/home/project:cached" theiaide/theia
mvn clean install
java -jar ./target/test-0.0.1-SNAPSHOT-jar-with-dependencies.jar
Maybe this issue related to
The text was updated successfully, but these errors were encountered: