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

view() shows websockets disconnection #99

Closed
Ljupch0 opened this issue Mar 16, 2023 · 10 comments · Fixed by #101
Closed

view() shows websockets disconnection #99

Ljupch0 opened this issue Mar 16, 2023 · 10 comments · Fixed by #101
Assignees

Comments

@Ljupch0
Copy link

Ljupch0 commented Mar 16, 2023

Hi, I am coming back to code that used to work.

Now when calling b$View() I immediately get
"Debugging connection was closed. Reason: WebSocket disconnected"

When I click reconnect devtools it immediately disconnects.

Is this some IT security thing?

image001

@wch
Copy link
Collaborator

wch commented Mar 16, 2023

I think this is the same issue as rstudio/shinytest2#331.

@gadenbuie
Copy link
Member

I wonder if it's related to recent changes to headless mode in Chrome? IIUC, as of Chrome 112, headless mode now uses the same engine as headful mode where previously headless mode was a completely separate engine.

I don't know the full context but the timing is suspicious and the linked article mentions the live viewer explicitly, so it seems feasible that something might have changed in that area.

@wch
Copy link
Collaborator

wch commented Mar 19, 2023

It looks like this is due to a security change in Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=1422444#c5

One workaround is to add --remote-allow-origins=*, but I think that makes it too open. It would be better to use --remote-allow-origins=http:127.0.0.1:xxxx, where xxxx is the port number. However, the problem with that is that we currently don't set the port number -- we let Chrome choose it when we use the option --remote-debugging-port=0. So for a proper fix, we might need to randomly select a port in R, then pass that port number to Chrome when starting it up.

@wch
Copy link
Collaborator

wch commented Mar 19, 2023

I made a workaround for testing in #100. You can try it with:

remotes::install_github("rstudio/chromote@origin-testfix")

@gadenbuie
Copy link
Member

@wch Since chromote doesn't currently expose an option to set the port, should it internally find a random port? Or would you prefer to expose an argument for setting the port number?

@wch
Copy link
Collaborator

wch commented Mar 20, 2023

I think it makes sense to always find a random port. I can't think of a reason offhand why one would need a specific port number.

@edwardhealey
Copy link

hey @wch, I am still getting the same issue as #99 when I install the package via remotes::install_github("rstudio/chromote") and run

library(chromote)

chrome <- ChromoteSession$new()
chrome$view()

@gadenbuie
Copy link
Member

@edwardhealey Are you getting the exact same behavior and error messages? I would expect a slightly different error message to be reported in the R console than was originally reported here. It's possible that error message may be informative. Can you include anything printed in the R console? Can you also please report your operating system and the version of Chrome you're using?

@wch
Copy link
Collaborator

wch commented Mar 27, 2023

@edwardhealey I just bumped the version number to 0.1.1.9001, so please reinstall, test it, and if it still fails, please include the output from sessioninfo::session_info().

@zsigmas
Copy link

zsigmas commented Mar 30, 2023

@edwardhealey For me it seemed that installing the fix provided by wch was not enough, but I needed to also update chromium for the $view to work again. I assume it was the update as in a given moment $view was working with google-chrome (installed after finding this problem to test if that solved the problem, so most recent version) but not in chromium (an undetermined older version).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants