Open nikitavbv opened 3 years ago
Please see https://github.com/atroche/rust-headless-chrome/pull/262 for a fix.
Please see https://github.com/atroche/rust-headless-chrome/pull/262 for a fix.
Hello I will review this on Monday, i don't have access to my pc currently. Sorry for the delay
Hi! Thank you for maintaining this crate!
It seems that browser process creation fails when running inside gVisor (used in environments like Google Cloud Run).
Browser::new
returnsDebugPortInUse
even though the port specified inLaunchOptions
is actually free.Steps to reproduce
Cargo.toml
:Here is
src/main.rs
, where we start a headless browser with a specific debugging port set (if we don't set it, it will give up after certain number of retries saying that no port was found):Dockerfile
:Build it using:
Now run the container:
You may see the following output:
That is something you may expect to see - the browser was successfully started, the webpage was loaded and the screenshot was made.
Now let's try to run the same container inside gVisor. You can find this runtime in Cloud Run (inside Google Cloud), or by installing it locally and running using:
You will probably get the following output:
Cause of this issue
If you take a look at chromium binary output, you may notice the following message:
I am not sure completely at the moment what this error message means, but I do know that it can be ignored. If you don't interrupt the process the moment you see this message, the browser finishes the startup and webtools websocket becomes available at the port, which was specified in the
LaunchOptions
.But the process actually gets interrupted. The regular expression in process.rs matches the error message above.
Proposed fix
One simple way to fix this problem would be to change this regexp to a more specific one or to ignore the
Could not bind NETLINK socket
message. I will send a PR soon with this change. Please let me know if you have any ideas for a better fix.Thank you!