GoogleChromeLabs / lighthousebot

Run Lighthouse in CI, as a web service, using Docker. Pass/Fail GH pull requests.
Apache License 2.0
2.24k stars 127 forks source link

Error: no such file or directory, /home/chrome/reports/report.<hash>.json #49

Open nolanlawson opened 5 years ago

nolanlawson commented 5 years ago

Hi, thanks for putting this tool together. I tested it out using the public server, and ran into the output:

Error from CI backend. invalid json response body at https://builder-dot-lighthouse-ci.appspot.com/ci reason: Unexpected token < in JSON at position 0

Thinking it was a problem with the public server, I deployed a Docker container as described in the docs. The container had the same issue, though.

So I manually ran the curl command as so:

curl -X POST \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: $LIGHTHOUSE_API_KEY" \
  --data '{"output": "json", "url": "http://example.com"}' \
  https://<container url>/ci

And I got the output:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Error: ENOENT: no such file or directory, stat &#39;/home/chrome/reports/report.1544322152932.json&#39;</pre>
</body>
</html>

Perhaps something changed in the way Lighthouse generated its reports?

nolanlawson commented 5 years ago

Of course, I can't reproduce when I run the Docker container locally :weary:

nolanlawson commented 5 years ago

Aha, so this appears to be the error output in the container. Looks like "no usable sandbox, please update your kernel." If this is happening in my own container, maybe it's happening in the public one too?

click here to see error output ``` 2018-12-09T02:50:21.882Z Sun, 09 Dec 2018 02:50:21 GMT ChromeLauncher Waiting for browser....................................................................................................... 2018-12-09T02:50:21.904Z 2018-12-09T02:50:21.926Z Sun, 09 Dec 2018 02:50:21 GMT ChromeLauncher:error connect ECONNREFUSED 127.0.0.1:38901 2018-12-09T02:50:21.948Z 2018-12-09T02:50:21.970Z Sun, 09 Dec 2018 02:50:21 GMT ChromeLauncher:error Logging contents of /tmp/lighthouse.aPL90E2/chrome-err.log 2018-12-09T02:50:21.992Z 2018-12-09T02:50:22.014Z Sun, 09 Dec 2018 02:50:21 GMT ChromeLauncher:error [1209/024956.632643:FATAL:zygote_host_impl_linux.cc(116)] No usable sandbox! Update your kernel or see https://chromium.googlesou rce.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try u sing --no-sandbox. 2018-12-09T02:50:22.036Z Failed to generate minidump. 2018-12-09T02:50:22.058Z 2018-12-09T02:50:22.080Z Unable to connect to Chrome 2018-12-09T02:50:22.102Z 2018-12-09T02:50:22.133Z Error: ENOENT: no such file or directory, stat '/home/chrome/reports/report.1544323795837.json' 2018-12-09T02:50:21.931Z Error: ENOENT: no such file or directory, unlink './home/chrome/reports/report.1544323795837.json' ```
nolanlawson commented 5 years ago

Just occurred to me that, for my container anyway, the problem is probably that it's not running with --cap-add=SYS_ADMIN as specified in this repo's README.

nolanlawson commented 5 years ago

Oddly, even after fixing the SYS_ADMIN issue and verifying that the curl command to /ci works correctly, the lighthouse-ci command still fails in Travis. (https://github.com/nolanlawson/pinafore/pull/793)

Since the proximate cause is that the client expects JSON and is getting HTML (probably an error page), maybe this is the same issue happening for the main lighthouse-ci server?

amkayondo commented 4 years ago

@nolanlawson did you find a fix for this 😃