Fix no inspectable targets issue with Chrome Browser#4696
Conversation
…ed headless browser It can happen with Chrome browser on windows that no target is available at start #4653
…o retry `maxTries` time
cscheid
left a comment
There was a problem hiding this comment.
with respect to changes on chrome.js: you'll note that this is a port of a library written by someone else. Fantastic that you found the issue and fixed it.
But I wonder if we should also check the upstream for updates, and set up a more formal fork rather than just change this one directly. (We can do that during 1.4)
This code path should be getting tested during our mermaid rendering tests. Ideally we'd make an isolated test, but I think we're at least covered. |
I did not realize this one file from a library 🤦 it was in Do you know the repo for this ? I can PR there maybe Otherwise in #4704 we can do a git patch approach as I recently add to |
|
@cderv The facepalm is mine! I made the port, so I should know. But I don't remember. It shouldn't be hard to find. |
|
This one probably : https://github.com/cyrus-and/chrome-remote-interface ? |
Fix #4653
Issue is that somehow Chrome browser open in headless mode with no target available at
json/endpoint.The logic to solve is to create a new tab if no target is already available. This way there will be a new target with websocket url to use.
Another solution would be to default to
json/versionendpoint (devtools.Version(option)fromdevtools.js) to get the browser websocket urlBut it feels like the former is good enough and better as we prefer page type for the ws url, so I went with that.
This PR will add to the
defaultTarget()handler the creation of a new tab usingjson/newif no targets is to inspect.I wasn't sure where to put this here or not, we could also move it upper in the stack in
_fetchDebuggerURL()directly, instead of onlydefaultTarget(). It would be more generic.This PR also fix an issue I found while working on it - if
clientis created without error, no need to trymaxTries(5) timesHope this is good. Not sure how to add tests for this quite specific fix.
Tested locally and it works for me.