This repository was archived by the owner on Jan 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
This repository was archived by the owner on Jan 30, 2025. It is now read-only.
Unhelpful context canceled warnings in response categories #968
Copy link
Copy link
Closed
Description
When running the following script against a remote chrome browser:
import { check } from 'k6';
import { browser } from 'k6/experimental/browser';
export const options = {
scenarios: {
ui: {
executor: 'shared-iterations',
vus: 5,
iterations: 1000,
maxDuration: '40m',
options: {
browser: {
type: 'chromium',
},
},
},
},
thresholds: {
checks: ["rate==1.0"]
}
}
export default async function () {
const context = browser.newContext();
const page = context.newPage();
try {
// Goto front page, find login link and click it
await page.goto('https://test.k6.io/', { waitUntil: 'networkidle' });
await Promise.all([
page.waitForNavigation(),
page.locator('a[href="/my_messages.php"]').click(),
]);
// Enter login credentials and login
page.locator('input[name="login"]').type('admin');
page.locator('input[name="password"]').type('123');
// We expect the form submission to trigger a navigation, so to prevent a
// race condition, setup a waiter concurrently while waiting for the click
// to resolve.
await Promise.all([
page.waitForNavigation(),
page.locator('input[type="submit"]').click(),
]);
check(page, {
'header': page.locator('h2').textContent() == 'Welcome, admin!',
});
} finally {
page.close();
}
}
We're seeing the logs such as these:
url:https://test.k6.io/static/css/site.css method:GET err:fetching response body: context canceled category=Response:bodySize:fetchBody elapsed=0 ms goroutine=23923 iteration_id=b3d4aaa99ecb1e93
url:https://test.k6.io/ method:GET err:fetching response body: context canceled category=Response:bodySize:fetchBody elapsed=0 ms goroutine=49974 iteration_id=3ecfa4d4951c0dc1
url:https://test.k6.io/static/css/site.css method:GET err:fetching response body: context canceled category=Response:bodySize:fetchBody elapsed=0 ms goroutine=103247 iteration_id=27a6c3b458836b13
url:https://test.k6.io/my_messages.php method:GET err:fetching response body: context canceled category=Response:bodySize:fetchBody elapsed=0 ms goroutine=136093 iteration_id=3a449dfc27ff1fdc
A user may infer that something has gone wrong and worth looking into, or maybe the test isn't hasn't worked as expected. However what these logs actually denote is that the test iteration has completed and we're moving onto the next test without waiting for the page's dependencies to load.
- In the long term we may want to give the user the choice to wait for all (some) dependencies to load, just as a real user would do to be able to visualise the rendered website;
- In the short term, the browser module can ignore such logs and not wait for all dependencies to load.
Test run id: 154420