REditorSupport / REditorSupport/languageserver
How to debug language server
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 675
- Forks
- 118
- Avg merge
- 1d 37m
- Merged PRs (30d)
- 11
Description
Hi
How can users of the language server debug it?
I have a valid R file which seems to reliably cause a textDocument/documentSymbol to time out without a response.
I would like to try to debug a running language server, but I am struggling a bit to figure out the workflow.
I started to use tests/testthat/test-symbol.R as a template and I was able to observe this in the log:
[2021-02-16 22:43:16.866] did save: {
"uri": "file:///home/miles/code/r/blogdown_test/content/post/test.R"
}
[2021-02-16 22:43:17.089] parse_callback called: {
"uri": "file:///home/miles/code/r/blogdown_test/content/post/test.R",
"version": null
}
[2021-02-16 22:43:17.641] resolve_callback called: {
"uri": "file:///home/miles/code/r/blogdown_test/content/post/test.R",
"version": null
}
[2021-02-16 22:43:18.153] received: Content-Length: 159
[2021-02-16 22:43:18.164] received payload.
[2021-02-16 22:43:18.165] handling request: textDocument/documentSymbol
[2021-02-16 22:43:18.165] document definitions found: 0
[2021-02-16 22:43:18.166] deliver: ["Response", "Message", "R6"]
[2021-02-16 22:43:18.572] received: Content-Length: 159
[2021-02-16 22:43:18.584] received payload.
[2021-02-16 22:43:18.585] handling request: textDocument/documentSymbol
[2021-02-16 22:43:18.586] document definitions found: 0
[2021-02-16 22:43:18.588] deliver: ["Response", "Message", "R6"]
[2021-02-16 22:43:18.896] received: Content-Length: 159
[2021-02-16 22:43:18.907] received payload.
[2021-02-16 22:43:18.907] handling request: textDocument/documentSymbol
[2021-02-16 22:43:18.907] document definitions found: 0
[2021-02-16 22:43:18.908] deliver: ["Response", "Message", "R6"]
[2021-02-16 22:43:19.216] received: Content-Length: 159
[2021-02-16 22:43:19.228] received payload.
[2021-02-16 22:43:19.229] handling request: textDocument/documentSymbol
[2021-02-16 22:43:19.230] document definitions found: 0
[2021-02-16 22:43:19.233] deliver: ["Response", "Message", "R6"]
[2021-02-16 22:43:19.645] received: Content-Length: 159
[2021-02-16 22:43:19.657] received payload.
[2021-02-16 22:43:19.658] handling request: textDocument/documentSymbol
[2021-02-16 22:43:19.659] document definitions found: 0
[2021-02-16 22:43:19.660] deliver: ["Response", "Message", "R6"]
[2021-02-16 22:43:20.071] received: Content-Length: 159
[2021-02-16 22:43:20.083] received payload.
[2021-02-16 22:43:20.084] handling request: textDocument/documentSymbol
[2021-02-16 22:43:20.086] document definitions found: 0
[2021-02-16 22:43:20.088] deliver: ["Response", "Message", "R6"]
[2021-02-16 22:43:20.396] received: Content-Length: 159
[2021-02-16 22:43:20.408] received payload.
[2021-02-16 22:43:20.409] handling request: textDocument/documentSymbol
[2021-02-16 22:43:20.410] document definitions found: 0
[2021-02-16 22:43:20.413] deliver: ["Response", "Message", "R6"]
[2021-02-16 22:43:20.822] received: Content-Length: 159
[2021-02-16 22:43:20.835] received payload.
[2021-02-16 22:43:20.836] handling request: textDocument/documentSymbol
[2021-02-16 22:43:20.837] document definitions found: 0
[2021-02-16 22:43:20.839] deliver: ["Response", "Message", "R6"]
[2021-02-16 22:43:21.252] received: Content-Length: 160
[2021-02-16 22:43:21.264] received payload.
[2021-02-16 22:43:21.265] handling request: textDocument/documentSymbol
[2021-02-16 22:43:21.266] document definitions found: 0
[2021-02-16 22:43:21.269] deliver: ["Response", "Message", "R6"]
[2021-02-16 22:43:21.681] received: Content-Length: 160
[2021-02-16 22:43:21.693] received payload.
[2021-02-16 22:43:21.693] handling request: textDocument/documentSymbol
[2021-02-16 22:43:21.694] document definitions found: 0
[2021-02-16 22:43:21.696] deliver: ["Response", "Message", "R6"]
[2021-02-16 22:43:22.107] received: Content-Length: 160
[2021-02-16 22:43:22.119] received payload.
[2021-02-16 22:43:22.120] handling request: textDocument/documentSymbol
[2021-02-16 22:43:22.121] document definitions found: 0
[2021-02-16 22:43:22.122] deliver: ["Response", "Message", "R6"]
[2021-02-16 22:43:22.534] received: Content-Length: 160
[2021-02-16 22:43:22.546] received payload.
[2021-02-16 22:43:22.547] handling request: textDocument/documentSymbol
[2021-02-16 22:43:22.549] document definitions found: 0
[2021-02-16 22:43:22.550] deliver: ["Response", "Message", "R6"]
[2021-02-16 22:43:22.962] received: Content-Length: 160
[2021-02-16 22:43:22.974] received payload.
[2021-02-16 22:43:22.975] handling request: textDocument/documentSymbol
[2021-02-16 22:43:22.976] document definitions found: 0
loop continues...
So it seems there is some issue in the symbol parsing setup. I would like to stick a browser() call in document_symbol_reply() to try to figure it out, but then need to be running the languageserver in an interactive session. So I can't figure out how to start a server interactively that I can address e.g. in my interactive session I tried:
languageserver::run(debug = "~/repos/languageserver/logs/log.txt", port = 8888)
Error in socketConnection(host = host, port = port, open = "r+b") :
cannot open the connection
In addition: Warning message:
In socketConnection(host = host, port = port, open = "r+b") :
localhost:8888 cannot be opened
Is this supposed to work? Looking into the code... wouldn't it need socketConnection(server = TRUE)?
Is there some way I can use the stdio mode and connect a language server client to a language server that isn't in a child process?
A bit lost. I am sure you have a good workflow for this. Please share!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tests/testthat/test-symbol.R, document_symbol_reply(), and languageserver::run() to understand the reported documentSymbol loop and current debug setup. Investigate the stdio and socket connection paths described in the issue. Done means documenting a reproducible workflow for interactively debugging a running language server, including how to connect a client and inspect symbol parsing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- devtools
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100