Unable to debug backend in a theia extension

I’m unable to debug the ‘backend’ part of the extension (i.e., breakpoints, step etc.). Can anyone guide me on this? Thanks !
Please refer to the sample theia application : https://github.com/cherxp/frontend-backend-theia-extn
.vscode/launch.json contains launch configuration.

[original thread by rs]

I was able to debug it without issues.

Where do you put a breakpoint?

[rs]

thank you @anton-kosyakov :slight_smile: I had put the breakpoint in both setclient (as shown by you) and performaction. Another point to note is that when i run in debug mode (using Launch Backend), the call setClient doesnt happen from frontend to backend.

What IDE do you use for debugging?

[rs]

I use Visual Studio Code. I checked this now … it works fine using VScode in Ubuntu 16. But, didnt work in Windows 10. Any clues?

unfortunately, no

[Nigel Westbury]

Yes, this is a known problem. See https://github.com/theia-ide/theia/issues/3590 . This issue happens on Windows only as it seems the scope of symbols is different on Windows vs Linux.

I don’t think @che-theia-new has problems with running the app, only with debugging. If symbols don’t match then the application don’t start at all.

[Nigel Westbury]

@anton-kosyakov It’s been a while since I looked at the issue, but IIRC in that issue the application did start but the new LSP was not started. This seems consistent with the comment “the call setClient doesnt happen from frontend to backend”. I may well be wrong and I have not tried this with the OP’s repo but I would guess that on Windows one will find ConnectionHandler twice in the map, one containing TestServerImpl and the other containing all the others. I will try it out if I get time.

super strange, it would mean that Symbol support for nodejs on windows is broken. I believe they test such things. @kittaakos did you experience something like that on Windows? It would be good if someone can debug proposed example on Windows and look for the root cause.

I could debug Theia on Windows, but I was never able to debug the backend for a downstream project on Windows. It was a Symbol problem for sure, but I cannot recall it.

[Nigel Westbury]

I’ve taken a look at the repo at https://github.com/cherxp/frontend-backend-theia-extn and I saw exactly what I predicted above. I have added the details to the issue.

[rs]

thank you, @westbury , @kittaakos , @anton-kosyakov . I tried debugging backend in theia code taken from github.
Added breakpoints to the following methods in file packages\filesystem\src\node\node-filesystem.ts:
FileSystemNode.createFile
FileSystemNode.createFolder

This seems to work. Used ‘Launch Backend’ configuration for debugging.

@che-theia-new could you please run yarn why @theia/core in your project on windows and post the output here? We need to exclude that you don’t have these package installed twice.

[rs]

thank you, @anton-kosyakov . Here is the output for the frontend-backend-theia-extn:
$ yarn why @theia/core
yarn why v1.7.0
[1/4] Why do we have the module “@theia/core”…?
[2/4] Initialising dependency graph…
[3/4] Finding dependency…
[4/4] Calculating file sizes…
=> Found “@theia/core@0.9.0”
info Reasons this module exists

  • project#serverevent” depends on it

  • Hoisted from “project#serverevent#@theia#core”

  • Hoisted from “project#electron-app#@theia#core”

  • Hoisted from “project#browser-app#@theia#core”

  • Hoisted from “project#browser-app#@theia#preferences#@theia#core”

  • Hoisted from “project#browser-app#@theia#navigator#@theia#core”

  • Hoisted from “project#electron-app#@theia#monaco#@theia#core”

  • Hoisted from “project#electron-app#@theia#messages#@theia#core”

  • Hoisted from “project#browser-app#@theia#markers#@theia#core”

  • Hoisted from “project#electron-app#@theia#languages#@theia#core”

  • Hoisted from “project#electron-app#@theia#workspace#@theia#core”

  • Hoisted from “project#electron-app#@theia#filesystem#@theia#core”

  • Hoisted from “project#browser-app#@theia#typescript#@theia#core”

  • Hoisted from “project#browser-app#@theia#editor#@theia#core”

  • Hoisted from “project#electron-app#@theia#terminal#@theia#core”

  • Hoisted from “project#electron-app#@theia#process#@theia#core”

  • Hoisted from “project#browser-app#@theia#typescript#@theia#callhierarchy#@theia#core”

  • Hoisted from “project#browser-app#@theia#preferences#@theia#json#@theia#core”

  • Hoisted from “project#electron-app#@theia#workspace#@theia#variable-resolver#@theia#core”

  • Hoisted from “project#browser-app#@theia#preferences#@theia#userstorage#@theia#core”

  • Hoisted from “project#electron-app#@theia#languages#@theia#output#@theia#core”

  • Hoisted from “project#electron-app#@theia#monaco#@theia#outline-view#@theia#core”
    Done in 4.23s.

thank you, unfortunately nothing suspicious

[rs]

@kittaakos , i have the same issue as yours :
“I could debug Theia on Windows, but I was never able to debug the backend for a downstream project on Windows.”

[rs]

@westbury , thank you. If backend debugging is working for “theia” in windows, can we use the same technique to make it work for the sample application too? (i’m not sure how)