Investigate puppeteer cache tests failing because responseCompleted is emitted too late
Categories
(Remote Protocol :: Agent, task, P2)
Tracking
(firefox130 fixed)
Tracking | Status | |
---|---|---|
firefox130 | --- | fixed |
People
(Reporter: jdescottes, Assigned: jdescottes)
References
Details
We added new tests using scripts instead of stylesheets to test cache scenarios with puppeteer.
Those tests seem to consistently pass upstream, however in our CI they fail intermittently.
An example of such a test looks like:
const {page, server} = await getTestState();
// Load and re-load to make sure it's cached.
await page.goto(server.PREFIX + url);
await page.setRequestInterception(true);
await page.setCacheEnabled(true);
page.on('request', request => {
return request.continue({}, 0);
});
const cached: HTTPRequest[] = [];
page.on('requestservedfromcache', r => {
return cached.push(r);
});
await page.reload();
expect(cached).toHaveLength(1);
The critical part here is that we call await page.reload();
and then expect that the cached request has already been received. This should be correct spec wise, because the cached request is for a script in the body of the page, so it should be fully loaded & parsed when load
is emitted. However since Firefox emits responseCompleted events slightly late, this fails intermittently. It seems to fail more frequently in cases where the HTML page was served with a 304 Not Modified (presumably we emit load
"faster" in this case?).
Fixing Bug 1882803 might address this issue, but otherwise we could update the tests to wait for the request instead of simply calling reload.
Assignee | ||
Updated•3 months ago
|
Assignee | ||
Comment 1•3 months ago
|
||
Tests have been enabled again.
Updated•3 months ago
|
Assignee | ||
Updated•3 months ago
|
Description
•