Skip to content
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

Help proxy for R errors #3753

Closed
iamYannC opened this issue Jun 30, 2024 · 42 comments
Closed

Help proxy for R errors #3753

iamYannC opened this issue Jun 30, 2024 · 42 comments
Assignees
Labels
area: help Issues related to Help category. bug Something isn't working lang: r os-windows Windows issue support

Comments

@iamYannC
Copy link

iamYannC commented Jun 30, 2024

Positron Version:

Positron Version: 2024.06.1 (system setup) build 2024.06.1-27
Code - OSS Version: 1.90.0
Commit: a893e5b
Date: 2024-06-26T01:33:58.809Z
Electron: 29.4.0
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.22631

Steps to reproduce the issue:

  1. type ?data_frame or any other ?

What did you expect to happen?

Open a help window

Were there any error messages in the output or Developer Tools console?

No error msg, but it just shows the html address and does not display the help documentation (only when hover, which is nice but not enough)
image

@iamYannC iamYannC added the bug Something isn't working label Jun 30, 2024
@juliasilge juliasilge added os-windows Windows issue area: help Issues related to Help category. labels Jun 30, 2024
@juliasilge
Copy link
Contributor

Seems like this is likely a problem with Windows only, as I cannot reproduce this on a Mac. Can you go to "Output" and see if there are related errors, such as in the "Extension Host" output channel?

@GitHunter0

This comment has been minimized.

@DavisVaughan

This comment has been minimized.

@GitHunter0

This comment has been minimized.

@iamYannC
Copy link
Author

iamYannC commented Jul 1, 2024

Seems like this is likely a problem with Windows only, as I cannot reproduce this on a Mac. Can you go to "Output" and see if there are related errors, such as in the "Extension Host" output channel?

Hey. Still with this bug.
I am not sure what you meant by Ext host, but i did find the log file, it's a bit long but here are the first lines, if that help a bit

2024-07-01 19:05:14.340 [info] Extension host with pid 16168 started
2024-07-01 19:05:14.340 [info] Skipping acquiring lock for c:\Users\97253\AppData\Roaming\Positron\User\workspaceStorage\5c969ba0f57a1e99e1f000f15ab1f060.
2024-07-01 19:05:14.358 [info] ExtensionService#_doActivateExtension vscode.emmet, startup: false, activationEvent: 'onLanguage'
2024-07-01 19:05:14.372 [info] ExtensionService#_doActivateExtension vscode.jupyter-adapter, startup: false, activationEvent: 'onLanguage:r', root cause: vscode.positron-r
2024-07-01 19:05:14.408 [info] ExtensionService#_doActivateExtension vscode.git-base, startup: false, activationEvent: '*', root cause: vscode.git
2024-07-01 19:05:14.434 [info] ExtensionService#_doActivateExtension vscode.positron-r, startup: false, activationEvent: 'onLanguage:r'
2024-07-01 19:05:14.464 [info] ExtensionService#_doActivateExtension vscode.git, startup: false, activationEvent: '*'
2024-07-01 19:05:14.509 [info] ExtensionService#_doActivateExtension vscode.github, startup: false, activationEvent: '*'

Otherwise, In the OUTPUT tab (next to problems, ports, debug etc..) there is not input.
image

--
F1: I get this pop-up:
image

@juliasilge
Copy link
Contributor

Can you run the command "Developer: Toggle Developer Tools" and take a look for logs related to Help? For me, I see this;

dev-tools-help

Which includes:

INFO PositronHelpService language runtime server sent show help event for: http://127.0.0.1:53548/library/base/html/data.frame.html

@iamYannC
Copy link
Author

iamYannC commented Jul 2, 2024

PositronHelpService langu

Filtering for help
image
vscode-app-1719906795045.log

Filtering for data.frame (the example i used)
image
vscode-app-1719906915661.log

And there was also that log (might be temp address? it changed):
vscode-app-1719906634973.log

Let me know if there is any additional info needed for you guys :)

@iamYannC
Copy link
Author

iamYannC commented Jul 2, 2024

Ok. I played with it with screen sharing and at one point something worked, but far less responsive than in rstudio..
When a small note appears in the bottom right its when i pressed F1 (with Fn button active)

example.mp4

@nstrayer
Copy link
Contributor

nstrayer commented Jul 2, 2024

@iamYannC, If you have the time, could you try this with python? E.g. switch to a python interpreter and run a help-generating command like ?load?

@iamYannC
Copy link
Author

iamYannC commented Jul 2, 2024

@iamYannC, If you have the time, could you try this with python? E.g. switch to a python interpreter and run a help-generating command like ?load?

Python's help works. takes a sec to load, but help page is loaded. tried with ?load, ?range and ?%copy and pd.read_csv - all works fine

btw, Julia's docu works but it only prints the help results in the consule, it doesnt open the documentation in the designated Julia extension area. But let's stick with R :P

@nstrayer
Copy link
Contributor

nstrayer commented Jul 2, 2024

Okay cool -- thanks for checking! This means something is going wrong in the R language pack end. @DavisVaughan or @lionel- does that seem like a correct assessment?

@jennybc
Copy link
Member

jennybc commented Jul 2, 2024

Observation re: the 3rd log (vscode-app-1719906634973.log):

I see the proxy being created at port 51197:

workbench.desktop.main.js:61147 [Extension Host] [HPM] Proxy created: /  -> http://127.0.0.1:51197

But the 502 error looks like a request on port 51301:

workbench.desktop.main.js:127455 DEBUG Webview(e2477533-89ab-4388-9864-96255b8e2083): webview ready
127.0.0.1:51301/library/base/html/data.frame.html:1 
        
        
       Failed to load resource: the server responded with a status of 502 (Bad Gateway)

In equivalent logging in my own Positron session just now, these two ports are the same (61588, yes, I know these ports are random):

[Extension Host] [HPM] Proxy created: /  -> http://127.0.0.1:61588
...
INFO PositronHelpService language runtime server sent show help event for: http://127.0.0.1:61588/library/base/html/data.frame.html

@iamYannC
Copy link
Author

iamYannC commented Jul 2, 2024

Observation re: the 3rd log (vscode-app-1719906634973.log):

I see the proxy being created at port 51197:

workbench.desktop.main.js:61147 [Extension Host] [HPM] Proxy created: /  -> http://127.0.0.1:51197

But the 502 error looks like a request on port 51301:

workbench.desktop.main.js:127455 DEBUG Webview(e2477533-89ab-4388-9864-96255b8e2083): webview ready
127.0.0.1:51301/library/base/html/data.frame.html:1 
        
        
       Failed to load resource: the server responded with a status of 502 (Bad Gateway)

In equivalent logging in my own Positron session just now, these two ports are the same (61588, yes, I know these ports are random):

[Extension Host] [HPM] Proxy created: /  -> http://127.0.0.1:61588
...
INFO PositronHelpService language runtime server sent show help event for: http://127.0.0.1:61588/library/base/html/data.frame.html

This is wayy too much SE for me but If needed, I can go on a remote session or if you guide me like @juliasilge did, i hope I could provide some other usefull logs.

I did not try from other computers so can't say if its something in my local machine or in-fact some bug.

Thanks for the attention!

@juliasilge
Copy link
Contributor

@iamYannC can you:

One will look like this:

[Extension Host] [HPM] Proxy created: / -> http://127.0.0.1:59984

The other will look like this:

INFO PositronHelpService language runtime server sent show help event for: http://127.0.0.1:59984/library/stats/html/lm.html

Notice that I, like @jennybc, have the same port in these two places. Do you have different ports?

@iamYannC
Copy link
Author

iamYannC commented Jul 3, 2024

@iamYannC can you:

One will look like this:

[Extension Host] [HPM] Proxy created: / -> http://127.0.0.1:59984

The other will look like this:

INFO PositronHelpService language runtime server sent show help event for: http://127.0.0.1:59984/library/stats/html/lm.html

Notice that I, like @jennybc, have the same port in these two places. Do you have different ports?

Hey. I cant understand its behaviour. It doesnt work, but then I just load a package (here, dplyr), and it's as if it brings up also the base R help documentation.
I did another video. I hope it also gives a clue as to what might happen. I tried either using ? or with pressing F1

--
Positron Version: 2024.06.1 (system setup) build 2024.06.1-54
Code - OSS Version: 1.90.0
Commit: 5115c73
Date: 2024-07-03T03:17:46.140Z
Electron: 29.4.0
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.22631

--
image

3 Log files for data frames
vscode-app-1720035176864.log
vscode-app-1720035192394.log
vscode-app-1720035200716.log

image
2 Log files
vscode-app-1720035326995.log
vscode-app-1720035337750.log

--
Here is what I did:

example.mp4

@juliasilge
Copy link
Contributor

@iamYannC do you mind rebooting your computer and then downloading the latest release to try again?

@juliasilge juliasilge added this to the Future milestone Jul 8, 2024
@iamYannC
Copy link
Author

iamYannC commented Jul 8, 2024

@iamYannC do you mind rebooting your computer and then downloading the latest release to try again?

Positron Version: 2024.07.0 (system setup) build 2024.07.0-17
Code - OSS Version: 1.90.0
Commit: 203958161106d234eaa85556293c1be8f8b395b3
Date: 2024-07-08T03:22:52.213Z
Electron: 29.4.0
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.22631

Same behviour.
Trying ?data.frame or ?data.frame() doesn't work. but then I just call a random help on a user-library function (without even loading, e.g ?glue::glue) and after that, ?data.frame works

Failed to load resource: the server responded with a status of 502 (Bad Gateway) - data.frame.html
vscode-app-1720475758729.log

On my second try it didnt load glue for the first time, so i re-ran it and it worked again..

https://github.com/posit-dev/positron/assets/130578277/c871f5ee-6e8e-483c-b919-c8df549e3407
Logs for failing ??glue and ?glue::glue
vscode-app-1720476182716 - log for calling glue package.txt
vscode-app-1720476212101 - log for calling glue function [failure].txt

@DavisVaughan
Copy link
Contributor

It would also be helpful to see your Console: R x.y.z output channel logs.

  • Toggle Command Palette
  • Search for Output: Show output channels
  • Choose the one for Console: R x.y.z where x.y.z is your version
  • Copy the entire log and paste it in or upload as a .log file
Screenshot 2024-07-09 at 6 00 02 PM

@iamYannC
Copy link
Author

iamYannC commented Jul 9, 2024

Console R 4.4.0.log

I think i keep getting these SEND heartbeat w tout 30 secs line printed..
I am curious to know if i am the only one with these issues

@DavisVaughan
Copy link
Contributor

Did you try and perform a help request before you captured those logs? I don't see a help request attempt anywhere in the logs. The heartbeat is normal.

@dengyuyueyuyue
Copy link

I also have the same issue: when typing ??function or help, the help window does not display properly and only shows a web link.
image

@iamYannC
Copy link
Author

iamYannC commented Jul 13, 2024

Did you try and perform a help request before you captured those logs? I don't see a help request attempt anywhere in the logs. The heartbeat is normal.

Console R 4.4.0.log

2024-07-13T20:17:22.817219Z ERROR No help port is available to check if 'http://127.0.0.1:31109/library/base/html/mean.html' is a help url. Is the help comm open?
[R] at crates\ark\src\interface.rs:1435

Another attempt yielded that line (log not attached):

2024-07-13T20:21:49.851336Z ERROR Error proxying http://localhost:14414/library/base/html/mean.html: error sending request for url (http://localhost:14414/library/base/html/mean.html): connection error: An established connection was aborted by the software in your host machine. (os error 10053)

@iamYannC
Copy link
Author

I also have the same issue: when typing ??function or help, the help window does not display properly and only shows a web link. image

https://youtu.be/DfxWhM8YTcw?t=202
Seems like we are not alone, also in python

@juliasilge
Copy link
Contributor

I'm bumping this back to triage since multiple people are running into this problem.

@juliasilge juliasilge removed this from the Future milestone Jul 15, 2024
@DavisVaughan
Copy link
Contributor

@iamYannC the Console: R logs are quite helpful, thanks!

@DavisVaughan
Copy link
Contributor

@iamYannC okay one more request. Please do exactly what you did before with the logs, but first go into Settings (Cmd + , on Mac) and change this setting to trace and then completely restart Positron. Forgot to tell you that earlier, so sorry.

Screenshot 2024-07-15 at 6 13 35 PM

@iamYannC
Copy link
Author

@iamYannC okay one more request. Please do exactly what you did before with the logs, but first go into Settings (Cmd + , on Mac) and change this setting to trace and then completely restart Positron. Forgot to tell you that earlier, so sorry.

Screenshot 2024-07-15 at 6 13 35 PM

Console R 4.4.0 with trace.log
I restarted positron after modifying the R log, but I still got this "Debug":
image

Just in case, I will restart and do that ?mean one more time, this time with a trace also in the console window:
Console R 4.4.0 with trace 2.log

@CongSIBR
Copy link

I have the same problem, which never happened before. Even after I restart my Mac and updated Positron.

Positron Version: 2024.07.0 (Universal) build 85
Code - OSS Version: 1.91.0
Commit: 9dfa34e
Date: 2024-07-22T04:48:59.704Z
Electron: 29.4.0
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin arm64 23.5.0

2024-07-22_positron.log
Screenshot 2024-07-22 at 16 32 18

@CongSIBR
Copy link

It's amazing, after working with VS Code for a while, I accidentally discovered that the positron issue was resolved! It's working now! I can see the help information.
I wonder if this issue could be related to VS Code.

@juliasilge juliasilge added this to the 2024.09.0 Pre-Release milestone Jul 22, 2024
@juliasilge
Copy link
Contributor

We haven't yet linked this discussion where folks are having similar problems: #3738

@DavisVaughan
Copy link
Contributor

DavisVaughan commented Jul 23, 2024

A couple thing I see in @iamYannC's latest logs

[R]   2024-07-21T12:06:27.854158Z  INFO  Proxying URL '"http://localhost:22825/library/base/html/mean.html"' path '/library/base/html/mean.html' content-type is 'Some("text/html")'
[R]     at crates\ark\src\help_proxy.rs:141
[R] 
[Positron] SEND heartbeat with timeout of 30 seconds
[R]   2024-07-21T12:06:32.224585Z  INFO  Proxying URL '"http://localhost:22825/doc/html/prism.css"' path '/doc/html/prism.css' content-type is 'Some("text/css")'
[R]     at crates\ark\src\help_proxy.rs:141
[R] 
[R]   2024-07-21T12:06:32.432514Z  INFO  Proxying URL '"http://localhost:22825/doc/html/prism.js"' path '/doc/html/prism.js' content-type is 'Some("text/javascript")'
[R]     at crates\ark\src\help_proxy.rs:141
[R] 
[R]   2024-07-21T12:06:32.638168Z  INFO  Proxying URL '"http://localhost:22825/doc/html/R.css"' path '/doc/html/R.css' content-type is 'Some("text/css")'
[R]     at crates\ark\src\help_proxy.rs:141
[R] 
[R]   2024-07-21T12:06:32.851731Z  INFO  Proxying URL '"http://localhost:22825/doc/html/katex-config.js"' path '/doc/html/katex-config.js' content-type is 'Some("text/javascript")'
[R]     at crates\ark\src\help_proxy.rs:141
[R] 
[R]   2024-07-21T12:06:33.060498Z  INFO  Proxying URL '"http://localhost:22825/doc/html/katex/katex.css"' path '/doc/html/katex/katex.css' content-type is 'Some("text/css")'
[R]     at crates\ark\src\help_proxy.rs:141
[R] 
[R]   2024-07-21T12:06:33.181138Z ERROR  Error proxying http://localhost:22825/doc/html/katex/katex.js: error sending request for url (http://localhost:22825/doc/html/katex/katex.js): operation was canceled: connection closed before message completed
[R]     at crates\ark\src\help_proxy.rs:177

And then a little later after a restart of R and another ?mean call

[R]   2024-07-21T12:07:05.690377Z ERROR  Error proxying http://localhost:18876/library/base/html/mean.html: error sending request for url (http://localhost:18876/library/base/html/mean.html): connection error: An existing connection was forcibly closed by the remote host. (os error 10054)
[R]     at crates\ark\src\help_proxy.rs:177

I think what this is telling me is that:

  • ?mean is correctly processed by ark, and we fire off ShowHelp for the R help url and send it to Positron
  • Positron then requests the help contents from ark at that url
  • Ark un-proxies the URL and then asks the R help server for the help contents

Something in that last step seems to be the issue?

@DavisVaughan
Copy link
Contributor

Also see this in @CongSIBR's logs

[R]   2024-07-22T08:32:01.448273Z ERROR  Error proxying http://localhost:28336/library/base/html/cut.html: error sending request for url (http://localhost:28336/library/base/html/cut.html): connection closed before message completed
[R]     at crates/ark/src/help_proxy.rs:177

@DavisVaughan
Copy link
Contributor

DavisVaughan commented Jul 23, 2024

After a bit of reading, it is possible that this error message is a known thing with users of reqwest/hyper
hyperium/hyper#2136

reqwest doesn't seem to have a retry mechanism baked in, which kind of blows my mind, but possibly we can try and add one using the again crate and this blog post as a model
https://stonecharioteer.com/posts/2022/rust-reqwest-retry.html

Or reqwest-retry, whichever seems more robust (ok, seems like this is the more robust one)
https://docs.rs/reqwest-retry/latest/reqwest_retry/
https://crates.io/crates/reqwest-retry

That's a first step, at least

@iamYannC
Copy link
Author

Very much appreciated @Posit team.
I will keep getting newest releases, hopefully it works out. If so I will post here

@CongSIBR
Copy link

Hi,
I’d like to know if this issue has been truly resolved. Since I encountered this problem last time, I’ve updated POSITRON two more versions, but the help information still doesn’t work, and the log information is still the same as before. Thank you.

@kv9898

This comment has been minimized.

@CorradoLanera

This comment was marked as off-topic.

@juliasilge

This comment was marked as off-topic.

@juliasilge juliasilge changed the title Help window does not work Help proxy for R errors Aug 23, 2024
@juliasilge juliasilge self-assigned this Aug 26, 2024
@juliasilge
Copy link
Contributor

QA Notes

Note that no one internally has been able to observe this class of problems so far.

In posit-dev/ark#489 I added retries to the Help proxy request.

  • Once the ark version in Positron is bumped, we expect that all kinds of Help requests continue to work in our internal automated and manual testing, like ?lm and ??lm.
  • Once a new public-facing build with this change integrated becomes available, we think (HOPE) that this will solve some or all of these problems observed with Help requests not showing up in the Help pane. We'll post here in this issue and in Help tab not working? #3738 when such a build is available.

Note

If you as a user continue to see problems (or see different kinds of problems), what is helpful is to change the R kernel log level to trace and share the logs from the R Console attached as a file to an issue. Let's have any users with further problems open a new issue because this one is getting hard to parse.

@testlabauto
Copy link
Contributor

Verified Fixed

Positron Version(s) : 2024.08.0-83
OS Version          : OSX & Windows

Test scenario(s)

Attempted to repro according to filing instructions with OSX and Windows and saw no issues.

Link(s) to TestRail test cases run or created:
N/A

@DavisVaughan
Copy link
Contributor

@testlabauto FYI this was actually closed a bit prematurely, as #4528 just pulled in the actual fix (it is unlikely you would have been able to trigger the bug anyways though, as none of us have ever actually seen it before)

@juliasilge
Copy link
Contributor

For folks who have been having trouble with the R Help proxy, the latest release incorporates the changes we hope will help or solve the problem. Please give it a try!

Note

If you as a user continue to see problems (or see different kinds of problems), what is helpful is to change the R kernel log level to trace and share the logs from the R Console attached as a file to an issue. Let's have any users with further problems open a new issue. Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: help Issues related to Help category. bug Something isn't working lang: r os-windows Windows issue support
Projects
None yet
Development

No branches or pull requests