languageserver icon indicating copy to clipboard operation
languageserver copied to clipboard

languageserver::run() results in Error: stdin connection close on Windoes 10

Open JanaJarecki opened this issue 5 years ago • 13 comments
trafficstars

languageserver::run() results in Error: stdin connection close on my Windows 10 machine

  • Rtools has been installed
  • The path to R (.../bin/x64) has been added as an environment variable
  • Rtools has also been added to the environment variables

Any idea whatelse I could try?

The background is that I want to use the rlang server with LSP on Sublimetext.

Thank you for the help, kind regards Jana

The full error message in R reads:

[2020-08-22 13:27:30.597] Error: stdin connection close                                  
Call: stdin_read_line()                                                                  
Stack trace:                                                                             
1: stdin_read_line()                                                                     
2: self$read_line()                                                                      
3: self$read_header()                                                                    
4: self$fetch(blocking = FALSE)                                                          
[2020-08-22 13:27:30.618] exiting

Session Info R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=German_Switzerland.1252 LC_CTYPE=German_Switzerland.1252
[3] LC_MONETARY=German_Switzerland.1252 LC_NUMERIC=C
[5] LC_TIME=German_Switzerland.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] compiler_3.6.3 R6_2.4.1 parallel_3.6.3
[4] tools_3.6.3 collections_0.3.5 xml2_1.3.2
[7] languageserver_0.3.6

JanaJarecki avatar Aug 22 '20 11:08 JanaJarecki

Update: An update to R 4.0.2 using rtools40 did not fix the issue

JanaJarecki avatar Aug 22 '20 13:08 JanaJarecki

Are you using the stdio mode? I think it is only supported on Linux and macOS but not on Windows, @randy3k?

renkun-ken avatar Aug 25 '20 01:08 renkun-ken

stdio mode should also work on Windows (it does not work in VSCode though because if an VScode issue).

Could you try running languageserver::run(debug=TRUE) and enable them stderr log of LSP to see what error you get?

randy3k avatar Aug 25 '20 01:08 randy3k

Dear Randy3k, first , many thanks for the work !

I am facing the same problem sor here is the output of the command languageserver::run(debug=TRUE) [2020-12-22 17:53:39.517] connection type: stdio [2020-12-22 17:53:39.976] Error: stdin connection close Call: stdin_read_line() Stack trace: 1: stdin_read_line() 2: self$read_line() 3: self$read_header() 4: self$fetch(blocking = FALSE) [2020-12-22 17:53:39.977] exiting

Below the 7-R Language Server.log of vscode during the problem (Sorry,I had to remove env section as it's not a personal PC) (found I could upload a file by drag & drop, so should be better for readability)

7-R Language Server.log

regards JJ

jj-9 avatar Dec 22 '20 17:12 jj-9

It seems that there may be an issue in counting numbver of bytes of large files in Windows?

[2020-12-22 18:09:51.683] received:  Content-Length: 37480

[2020-12-22 18:09:52.763] error handling json:  Error: lexical error: invalid char in json text.
                                       Content-Length: 37479    {"json
                     (right here) ------^

Stack trace:
1: parse_string(txt, bigint_as_char)
2: parseJSON(txt, bigint_as_char)
3: parse_and_simplify(txt = txt, simplifyVector = simplifyVector, 
    simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifyMatrix, 
    flatten = flatten, ...)
4: jsonlite::fromJSON(data, simplifyVector = FALSE)

What version of languageserver are you using?

randy3k avatar Dec 22 '20 19:12 randy3k

Hi !

I use the last ( 0.3.9 )

thanks for replying JJ

jj-9 avatar Dec 22 '20 19:12 jj-9

Is there a chance your file contains non-unicode characters?

randy3k avatar Dec 22 '20 19:12 randy3k

There could because on my source code is usually use windows-1252 but I also tried encoding as utf8 and I got same error

JJ

jj-9 avatar Dec 22 '20 19:12 jj-9

windows-1252 is definitely problematic as language servers only support UTF-8. I am not sure why it still fail for UTF-8 though.

randy3k avatar Dec 23 '20 06:12 randy3k

Hi Randy3k

good news !

I checked with a fresh new UTF-8 project to be sure to have 0 files in W1252 and actually it seems not to crash. So I think I still had some win1252 encoded files on my first try, even if I didn't find it . (in anycase of crash with UTF-8 I will tell, but as it's been active for half an hour doing lintr corrections with no problem I think it's ok)

Sorry for the bad informationin previous message, and once more, many thanks for your work.

For what I'm concerned, I think you could close this issue.

Best regards JJ

jj-9 avatar Dec 23 '20 09:12 jj-9

Dear @randy3k , First I wish you have the best possible year ! (at least better than the previous one !)

I finally manage to reproduce the error even with an UTF-8 file. From the attached file (renamed by removing the .txt extension) : test.fichier1.R.txt

1 - Open a folder with the file in it 2 - Open the file 3 - correct one of the numerous lintr incorrect point (say, the space at the end of line 135) 4 - If not crashed, save the file 5 - If still not crashed, re-type the space at the end of the line at this point should have crashed. If not, you can try by copying/pasting one of the print(...) paragraphs to get the error.

(context is exactly same as previously posted R language server log)

Second EDIT : it seems to happen on the second loading of the file, not the first time (ie when you open a file it's ok , when you read or wait, it parses again and then crashes)

Best regards JJ

jj-9 avatar Jan 04 '21 15:01 jj-9

After the integration of r-lsp into vscode-r, I got:

r$> languageserver::run()
[2021-08-10 15:21:57.495] Error: stdin connection close
Call: stdin_read_line()
Stack trace:
1: stdin_read_line()
2: self$read_line()
3: self$read_header()
4: self$fetch(blocking = FALSE)
[2021-08-10 15:21:57.503] exiting

This is the error message of languageserver::run() in radian, but in the extension settings use_stdio is disabled. I also tried languageserver::run(port = 8888) and I got the following error message:

r$> languageserver::run(port = 8888)
[2021-08-10 15:30:07.731] connection type: tcp at  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

EvoLandEco avatar Aug 10 '21 13:08 EvoLandEco

[2021-08-10 15:44:33.141] diagnostics session init error 1 {
  "code": 501,
  "message": "R session crashed with exit code 1",
  "result": null,
  "stdout": "",
  "stderr": "Error: 24:31: unexpected symbol\r\n24: options(vsc.use_httpgd = TRUE)options\r\n                                   ^\r\nExecution halted\r\n",
  "error": {
    "message": "R session crashed with exit code 1"
  }
}

[2021-08-10 15:44:33.201] diagnostics session init error 2 {
  "code": 501,
  "message": "R session crashed with exit code 1",
  "result": null,
  "stdout": "",
  "stderr": "Error: 24:31: unexpected symbol\r\n24: options(vsc.use_httpgd = TRUE)options\r\n                                   ^\r\nExecution halted\r\n",
  "error": {
    "message": "R session crashed with exit code 1"
  }
}

[2021-08-10 15:44:33.275] parse session init error 1 {
  "code": 501,
  "message": "R session crashed with exit code 1",
  "result": null,
  "stdout": "",
  "stderr": "Error: 24:31: unexpected symbol\r\n24: options(vsc.use_httpgd = TRUE)options\r\n                                   ^\r\nExecution halted\r\n",
  "error": {
    "message": "R session crashed with exit code 1"
  }
}

[2021-08-10 15:44:33.328] parse session init error 2 {
  "code": 501,
  "message": "R session crashed with exit code 1",
  "result": null,
  "stdout": "",
  "stderr": "Error: 24:31: unexpected symbol\r\n24: options(vsc.use_httpgd = TRUE)options\r\n                                   ^\r\nExecution halted\r\n",
  "error": {
    "message": "R session crashed with exit code 1"
  }
}

[2021-08-10 15:44:33.393] parse session init error 3 {
  "code": 501,
  "message": "R session crashed with exit code 1",
  "result": null,
  "stdout": "",
  "stderr": "Error: 24:31: unexpected symbol\r\n24: options(vsc.use_httpgd = TRUE)options\r\n                                   ^\r\nExecution halted\r\n",
  "error": {
    "message": "R session crashed with exit code 1"
  }
}

Above is what I got in the output tab if I also enable the R LSP Client extension. If I disable it then there is nothing in the output if I restart vscode.

EvoLandEco avatar Aug 10 '21 13:08 EvoLandEco