Skip to content

Resume on error #1239

Description

@dennis-tra

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?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions