[Error] Large Test segmentation fault (core dumped) error

Hello k6 Community,

I’ve been working on a project using k6-browser and encountered a couple of critical errors that I’m unable to resolve. I’m hoping someone here might have insights or suggestions on how to fix these issues.
This is the script im using:

import { browser } from 'k6/experimental/browser';
import { scenario } from 'k6/execution'
import {getSafeIndex} from "./helpers/helpers.js";

export const options = {
  scenarios: {
    browser: {
      executor: 'ramping-vus',
      startVUs: 0,
      stages: [
        { duration: '300s', target: 100 },
        { duration: '3300s', target: 100 },
      ],
      gracefulRampDown: '60s',
      options: {
        browser: {
          type: 'chromium',
        }
      }
    }
  } 
}

let datosSalariales = JSON.parse(open("./data.json"));

export default async function() {
  let index = getSafeIndex(scenario.iterationInTest, datosSalariales)
  let socio = data[index].EMPRESA;
  let productor = data[index].EMPLEADO;
  let observacion = data[index].OBSERVACIONES;

  const page = browser.newPage();
  try{
    await page.goto('https://some.page.jsp', {waitUntil: 'networkidle'})

    page.locator('//input[@name="LOGIN"]').type('User', {delay: 50})
    page.locator('//input[@name="PASSWORD"]').type('Password', {delay: 50})
    
    const entrar = page.locator('//input[@name="enviar"][@value="Aceptar"]')
    await entrar.click()

    page.waitForTimeout(500) 
    
    const confirmFrameHandle = page.waitForSelector('//frame[@name="contenidos"]')
    const confirmFrame = confirmFrameHandle.contentFrame()
    const password2 = confirmFrame.waitForSelector('#P_PTIE')
    await password2.type('jcazalil', {delay: 50})

    await page.waitForLoadState('networkidle');

    const confirmFrameHandle2 = page.waitForSelector('//frame[@name="contenidos"]')
    const confirmFrame2 = confirmFrameHandle2.contentFrame()
    const entrar2 = confirmFrame2.waitForSelector('//input[@name="enviar"]')
    await entrar2.click()

    page.waitForTimeout(500) 

    const confirmFrameHandle3 = page.waitForSelector('//frame[@name="contenidos"]')
    const confirmFrame3 = confirmFrameHandle3.contentFrame()
    const datosSalariares = confirmFrame3.waitForSelector('//a[@href="rhtids.jsp"]')
    await datosSalariares.click()

    page.waitForTimeout(500) 

    const confirmFrameHandle4 = page.waitForSelector('//frame[@name="contenidos"]')
    const confirmFrame4 = confirmFrameHandle4.contentFrame()
    const soc = confirmFrame4.locator('#P_SOC')
    await soc.type(socio, {delay: 50})

    page.waitForTimeout(500)

    const confirmFrameHandle5 = page.waitForSelector('//frame[@name="contenidos"]')
    const confirmFrame5 = confirmFrameHandle5.contentFrame()
    const prod = confirmFrame5.locator('#P_PROD')
    await prod.type(productor, {delay: 50})

    page.waitForTimeout(500)

    const confirmFrameHandle6 = page.waitForSelector('//frame[@name="contenidos"]')
    const confirmFrame6 = confirmFrameHandle6.contentFrame()
    const mostrarResultados = confirmFrame6.locator('//input[@name="filtrar"]')
    await mostrarResultados.click()

    page.waitForTimeout(500)

    const confirmFrameHandle7 = page.waitForSelector('//frame[@name="contenidos"]')
    const confirmFrame7 = confirmFrameHandle7.contentFrame()
    const observaciones = confirmFrame7.locator('#P_OBS')
    await observaciones.fill(observacion)

    page.waitForTimeout(500)

    const confirmFrameHandle8 = page.waitForSelector('//frame[@name="contenidos"]')
    const confirmFrame8 = confirmFrameHandle8.contentFrame()
    const aceptarObservacion = confirmFrame8.locator('#enviar')
    await aceptarObservacion.click()

    page.waitForTimeout(500)
  }finally{
    page.close()
  }
}

Below are the details of the problems:

running (0h31m42.9s), 100/100 VUs, 11458 complete and 0 interrupted iterations
browser   [  92% ] 100 VUs  0h31m42.9s/1h0m0s  11458/12500 shared iters
time="2024-04-15T15:03:58Z" level=error msg="process with PID 811627 unexpectedly ended: signal: segmentation fault (core dumped)" category=browser elapsed="0 ms" source=browser
...
time="2024-04-15T15:04:04Z" level=warning error="context is done before all 'IterEnd' events were processed"
time="2024-04-15T15:04:04Z" level=error msg="process with PID 811256 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:04Z" level=error msg="process with PID 811626 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:04Z" level=error msg="process with PID 811512 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:04Z" level=warning error="context is done before all 'IterEnd' events were processed"
time="2024-04-15T15:04:04Z" level=warning error="context is done before all 'IterEnd' events were processed"
time="2024-04-15T15:04:04Z" level=error msg="process with PID 811732 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser

running (0h31m48.8s), 000/100 VUs, 11458 complete and 100 interrupted iterations
browser ✗ [  92% ] 100 VUs  0h31m43.0s/1h0m0s  11461/12500 shared iters
time="2024-04-15T15:04:04Z" level=error msg="process with PID 811212 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:04Z" level=error msg="process with PID 811875 unexpectedly ended: context canceled" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:05Z" level=error msg="process with PID 811873 unexpectedly ended: context canceled" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:05Z" level=error msg="process with PID 811645 unexpectedly ended: context canceled" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:05Z" level=error msg="process with PID 811620 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser

     browser_data_received.......: 14 GB  7.3 MB/s
     browser_data_sent...........: 478 MB 250 kB/s
     browser_http_req_duration...: avg=11.37ms  min=38µs    med=77µs    max=6.51s    p(90)=31.95ms  p(95)=51ms
     browser_http_req_failed.....: 0.00%  ✓ 0        ✗ 1155904
     browser_web_vital_cls.......: avg=0.004134 min=0       med=0       max=0.085224 p(90)=0        p(95)=0.06906
     browser_web_vital_fcp.......: avg=120.9ms  min=25.69ms med=88ms    max=5.98s    p(90)=191.06ms p(95)=300.59ms
     browser_web_vital_fid.......: avg=1.37ms   min=0s      med=400µs   max=465.39ms p(90)=2.69ms   p(95)=5.29ms
     browser_web_vital_inp.......: avg=95.18ms  min=0s      med=16ms    max=4.25s    p(90)=56ms     p(95)=1.21s
     browser_web_vital_lcp.......: avg=120.9ms  min=0s      med=85.39ms max=6.01s    p(90)=195.9ms  p(95)=305.84ms
     browser_web_vital_ttfb......: avg=40.7ms   min=8.5ms   med=32.9ms  max=5.2s     p(90)=58.9ms   p(95)=66.89ms
     data_received...............: 0 B    0 B/s
     data_sent...................: 0 B    0 B/s
     iteration_duration..........: avg=15.55s   min=37.5µs  med=15.22s  max=44.35s   p(90)=17.11s   p(95)=17.84s
     iterations..................: 11459  6.003356/s
     vus.........................: 100    min=100    max=100
     vus_max.....................: 100    min=100    max=100


running (0h31m48.8s), 000/100 VUs, 11458 complete and 100 interrupted iterations
browser ✗ [  92% ] 100 VUs  0h31m43.0s/1h0m0s  11461/12500 shared iters
time="2024-04-15T15:04:05Z" level=error msg="process with PID 811866 unexpectedly ended: context canceled" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:05Z" level=error msg="process with PID 812132 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:05Z" level=error msg="process with PID 812000 unexpectedly ended: context canceled" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:05Z" level=error msg="process with PID 811634 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:05Z" level=error msg="process with PID 811699 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:05Z" level=error msg="process with PID 811356 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-15T15:04:05Z" level=error msg="error building browser on IterStart: launching browser: Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory at file:///prueba/script.js:23:15(0)"

The machine where im running this script have RHEL 8.4, with 16 vCPU and 64 GB RAM, where are installed chromium-headless & dependences and podman, and this is the command I run: podman run --rm --name=“k6pdr” --pids-limit=-1 --read-only=true -v /opt/k6/project/pruebas-plataforma/k6/:/prueba -i grafana/ k6:0.50.0-with-browser run /prueba/script.js.
“The test runs correctly for about the first 10,000 iterations. After that, sometimes this error occurs and sometimes it does not. What could be causing this and how can I fix it? Thank you for your help in advance.”

Hi @chw999999,

This error seems related to the operating system and settings used by the Docker container. Could you check out this link as people list some solutions that are possibly related to this issue.

Please let us know how it goes.

After following the guide you provided, I relaunched the test with the command:

podman run --rm --name="k6pdr" --pids-limit=-1 --read-only=true -v /opt/k6/pruebas/pruebas-plataforma/k6/:/prueba -v /run/dbus/system_bus_socket:/run/dbus/system_bus_socket -i grafana/k6:0.50.0-with-browser run /prueba/script.js

Now, I encounter a similar error:

time="2024-04-23T13:32:41Z" level=error msg="error building browser on IterStart: launching browser: Failed to connect to the bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. at file:///prueba/script.js:27:15(0)"

Below are the details

running (0h44m21.5s), 000/100 VUs, 11509 complete and 100 interrupted iterations
browser ✗ [  74% ] 085/100 VUs  0h44m17.7s/1h00m00.0s
time="2024-04-23T13:32:40Z" level=error msg="process with PID 803189 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-23T13:32:40Z" level=error msg="process with PID 801793 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-23T13:32:40Z" level=error msg="process with PID 804714 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-23T13:32:40Z" level=error msg="process with PID 804902 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-23T13:32:40Z" level=error msg="process with PID 804725 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser

     browser_data_received.......: 14 GB  5.3 MB/s
     browser_data_sent...........: 481 MB 181 kB/s
     browser_http_req_duration...: avg=9.32ms   min=39µs    med=78µs     max=7.2s     p(90)=24.49ms  p(95)=39.85ms
     browser_http_req_failed.....: 0.00%  ✓ 0        ✗ 1161267
     browser_web_vital_cls.......: avg=0.004398 min=0       med=0        max=0.085224 p(90)=0        p(95)=0.06906
     browser_web_vital_fcp.......: avg=98ms     min=27ms    med=76.8ms   max=6.58s    p(90)=124.79ms p(95)=174.9ms
     browser_web_vital_fid.......: avg=826.97µs min=0s      med=399.99µs max=236.59ms p(90)=1.1ms    p(95)=2.5ms
     browser_web_vital_inp.......: avg=411.46ms min=0s      med=16ms     max=3.76s    p(90)=2.2s     p(95)=2.23s
     browser_web_vital_lcp.......: avg=99.24ms  min=0s      med=73.69ms  max=6.81s    p(90)=127.69ms p(95)=180.6ms
     browser_web_vital_ttfb......: avg=41.64ms  min=9.09ms  med=34.79ms  max=7.2s     p(90)=63.59ms  p(95)=69.39ms
     data_received...............: 0 B    0 B/s
     data_sent...................: 0 B    0 B/s
     iteration_duration..........: avg=21.27s   min=39.93µs med=21.03s   max=50.37s   p(90)=22.26s   p(95)=22.82s
     iterations..................: 11515  4.326513/s
     vus.........................: 100    min=0      max=100
     vus_max.....................: 100    min=100    max=100


running (0h44m21.5s), 000/100 VUs, 11509 complete and 100 interrupted iterations
browser ✗ [  74% ] 085/100 VUs  0h44m17.7s/1h00m00.0s
time="2024-04-23T13:32:41Z" level=error msg="process with PID 804712 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-23T13:32:41Z" level=error msg="process with PID 803508 unexpectedly ended: context canceled" category=browser elapsed="0 ms" source=browser
time="2024-04-23T13:32:41Z" level=error msg="process with PID 804916 unexpectedly ended: context canceled" category=browser elapsed="0 ms" source=browser
time="2024-04-23T13:32:41Z" level=error msg="process with PID 804706 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-23T13:32:41Z" level=error msg="error building browser on IterStart: launching browser: Failed to connect to the bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. at file:///prueba/script.js:27:15(0)"

This is a much different message than the previous one. Now, the message says there is a bus to talk to, but there were problems:

  • the remote application did not send a reply
  • the message bus security policy blocked the reply
  • the reply timeout expired
  • the network connection was broken

Figuring out these problems depends on the configuration (OS, Docker, etc.) used. Although this issue doesn’t seem to be related to the browser module, we’ll let you know if we can find a solution.