-
-
Notifications
You must be signed in to change notification settings - Fork 140
Open
Labels
Description
Hey there,
I'm using the phantomas docker image to gather metrics about website performance in the following way:
docker run --network=host --privileged macbre/phantomas:latest /opt/phantomas/bin/phantomas.js --timeout=60s --url "https://website.com"
For this specific website, it sometimes works. But often receive:
Error: Navigation failed because browser has disconnected!
/opt/phantomas/bin/phantomas.js:50
debug("Metrics: %j", results.getMetrics());
^
TypeError: Cannot read properties of undefined (reading 'getMetrics')
at /opt/phantomas/bin/phantomas.js:50:34
Node.js v18.13.0
or
Error: HTTP response code from <https://website.com/fonts/vendor/jost/jost-v4-latin-regular.woff2> is 404
/opt/phantomas/bin/phantomas.js:50
debug("Metrics: %j", results.getMetrics());
^
TypeError: Cannot read properties of undefined (reading 'getMetrics')
at /opt/phantomas/bin/phantomas.js:50:34
Node.js v18.13.0
After reviewing the website, error message, and phantomas code, I discovered that the fonts were unable to load. As a result, phantomas came to a halt and stopped functioning altogether. I think that's the relevant code part:
Lines 146 to 167 in 1a7fb52
| var firstResponseReceived = false; | |
| events.once("recv", async (entry) => { | |
| if (!firstResponseReceived && entry.status >= 400) { | |
| debug( | |
| "<%s> response code is HTTP %d %s", | |
| entry.url, | |
| entry.status, | |
| entry.statusText | |
| ); | |
| // close the browser before leaving here, otherwise subsequent instances will have problems | |
| await browser.close(); | |
| reject( | |
| new Error( | |
| "HTTP response code from <" + entry.url + "> is " + entry.status | |
| ) | |
| ); | |
| } | |
| firstResponseReceived = true; | |
| }); |
We can fix the error of a dead link to font resources, but can we configure phantomas to ignore such errors and resume the measurement?
macbre and dennis-tra