Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resume on error #1239

Open
dennis-tra opened this issue Feb 28, 2023 · 0 comments
Open

Resume on error #1239

dennis-tra opened this issue Feb 28, 2023 · 0 comments

Comments

@dennis-tra
Copy link

dennis-tra commented Feb 28, 2023

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:

phantomas/lib/index.js

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants