Error building browser on IterStart: launching browser: browser process shutdown unexpectedly before establishing a connection: read |0: file already closed

I get the process shutdown unexpected error only when I run the below script in Alpine container with the latest k6 version (0.46.0) everything works as expected on mac. Do you have a sample dockerfile based on alpine image that is working?

// Frontend performance test simulating user interactions in a browser context
export async function frontendPerformanceTest() {
const page = browser.newPage();
try {
// Navigate to the login page
await page.goto(LOGIN_PAGE);

// Fill in the login form
const submitButton = page.locator('input[type="submit"]');

// Submit the form and wait for navigation
await Promise.all([page.waitForNavigation(),]);

// Check the title of the resulting page
check(page, {
  'titleCheck': p => p.title() == 'Dr. 1101 Broad - 459032965 - ServiceB',

} catch (error) {
console.error(“Error in frontendPerformanceTest:”, error.message);
} finally {
// Close the browser context

Here is the docker file i am using

FROM golang:alpine3.17 as builder

RUN go install

RUN xk6 build v0.46.0
–output /tmp/k6

FROM alpine:3.18


ADD . .

USER root

RUN apk update &&
apk --no-cache add gnupg &&
apk --no-cache add chromium

RUN npm ci


COPY --from=builder /tmp/k6 /usr/bin/k6

Hi @pviswanathan , welcome to the forum :wave:

We have a dedicated k6 docker image (grafana/k6:master-with-browser) that already contains a browser. You can see the definition here.

Thanks Daniel. It works now

Hi @Daniel.J ,

Just curious to understand the difference between chromium vs chromium-swiftshader. Why would one use chromium-swiftshader?

chromium-swiftshader is the version available in alpine linux. You can read more about it here.

1 Like