schickling / chromeless

🖥 Chrome automation made simple. Runs locally or headless on AWS Lambda.
https://chromeless.netlify.com
MIT License
13.24k stars 575 forks source link

Chromeless hangs forever when navigating #182

Open aml11 opened 7 years ago

aml11 commented 7 years ago

I found a URL where chromeless just never comes back (an exception would have been nice)

You can even reproduce it with the [demo](https://chromeless.netlify.com/#src=const%20chromeless%20=%20new%20Chromeless(%7B%20remote:%20true%20%7D)%0A%0Aconst%20screenshot%20=%20await%20chromeless%0A%20%20.goto('https://www.google.com/gen_204')%0A%20%20.scrollTo(0,%202000)%0A%20%20.screenshot()%0A%0Aconsole.log(screenshot)%0A%0Aawait%20chromeless.end())

The url is https://www.google.com/gen_204

Using curl I can see it responds with HTTP code 204

curl -v https://www.google.com/gen_204
*   Trying 216.58.205.228...
* TCP_NODELAY set
* Connected to www.google.com (216.58.205.228) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: www.google.com
* Server certificate: Google Internet Authority G2
* Server certificate: GeoTrust Global CA
> GET /gen_204 HTTP/1.1
> Host: www.google.com
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 204 No Content
< Content-Type: text/html; charset=ISO-8859-1
< P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."
< Date: Sun, 06 Aug 2017 14:00:28 GMT
< Server: gws
< Content-Length: 0
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< Set-Cookie: NID=109=H4ois4gUlWOW9CD1efAosaBMrblOpo5trSlAAWzZ-mmwk1V0z39kCqNvWAoLlPdbhzbATQYSFvSVmZzhkAICoaPauhLqsuPkI_Vf7_mQLwclXyXuDgfoL6mqVgsP05n0; expires=Mon, 05-Feb-2018 14:00:28 GMT; path=/; domain=.google.com; HttpOnly
< Alt-Svc: quic=":443"; ma=2592000; v="39,38,37,36,35"
<
* Connection #0 to host www.google.com left intact
lynchd commented 7 years ago

I had a similar experience for 3xx, 4xx and DNS errors. Basically anytime the response code is non-200

I'm defending against it using this for now ...

var request = require('request');
request(targetURL, function (error, response, body) {
  if (error || (response && response.statusCode!=200)) {
    console.log("Could not resolve targetURL")
    process.exit(-1)
  }
});