grafana / xk6-browser

k6 extension that adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol
https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/browser/
GNU Affero General Public License v3.0
331 stars 42 forks source link

Abort the iteration on panic even if caught #816

Open inancgumus opened 1 year ago

inancgumus commented 1 year ago

The following script should panic, end the iteration, and kill the browser.

The problem is, it panics and kills the browser, however, the test carries on until eventually times out.

import { chromium } from 'k6/x/browser';

export default async function() {
  const browser = chromium.launch({ headless: true });
  const context = browser.newContext();

  try {
    context.cookies();
    console.log("should not reach here");
  } catch (e) {
    console.log('check panicked: ' + e)
  } finally {
    browser.close();
  }
}

It seems the code stuck here (browser.close();) while sending the CDP browser close message since k6ext.Panic killed the browser.

Related: #815

inancgumus commented 8 months ago

I can't reproduce this anymore. Also, Pids() interface check seems to be stopped working when a panic occurs. For instance, context.exposeBinding() panics, but Panic misses the Pids() method.