7

I'm using chrome headless to take screenshots. But when adding a timeout, the process does not exit, it stays alive... Is there a way to kill the process on errors (like timeouts)?

Command without timeout and its output (this one is working):

>>> chrome --headless --screenshot --no-sandbox https://stackoverflow.com
[0808/174530.681784:ERROR:gpu_process_transport_factory.cc(1016)] Lost UI shared context.
Fontconfig warning: "/etc/fonts/fonts.conf", line 146: blank doesn't take any effect anymore. please remove it from your fonts.conf
[0808/174531.735502:ERROR:cert_verify_proc_nss.cc(981)] CERT_PKIXVerifyCert for securepubads.g.doubleclick.net failed err=-8179
[0808/174532.060892:INFO:headless_shell.cc(590)] Written to file screenshot.png.
>>> 

Command with timeout (at 1ms for testing) and its output (pending):

>>> chrome --headless --screenshot --no-sandbox --timeout=1 https://stackoverflow.com
[0808/174256.720003:ERROR:gpu_process_transport_factory.cc(1016)] Lost UI shared context.
Fontconfig warning: "/etc/fonts/fonts.conf", line 146: blank doesn't take any effect anymore. please remove it from your fonts.conf
[0808/174256.772496:INFO:headless_shell.cc(344)] Timeout.
Nicolas
  • 1,812
  • 3
  • 19
  • 43
  • 1
    did you figure out? I have similar problem – KKW Oct 03 '21 at 02:01
  • No, I have used an external script to manage timeout. – Nicolas Oct 03 '21 at 07:04
  • here is something interesting that i tried, when I tried timeout=10000 (which is 10 seconds), it worked for me. It seems like it won;t work until everything has been "loaded"? Try to increase your timeout and see if that works – KKW Oct 03 '21 at 20:38

1 Answers1

0

I prefered to use Linux command timeout. Here is the sample for you case, to wait 60 seconds then terminate the chrome instance.

>>> timeout 60 chrome --headless --screenshot --no-sandbox https://stackoverflow.com
Vincent
  • 16