Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

browser.isConnected doesn't seem to detect when the browser process is no longer running #453

@ankur22

Description

@ankur22

Tested against: dbede12

The browser.isConnected function doesn't seem to fully work as expected -- it doesn't correctly detect that there is no browser process running and therefore no valid CDP connection. Here's the test script I ran. When the test goes to sleep for 20seconds, that's when I force quit the browser process:

import launcher from 'k6/x/browser';
import { check, sleep } from 'k6';

export default function() {
  const browser = launcher.launch('chromium', {
    headless: false,
  });

  check(browser, {
    'should be connected after launch': browser.isConnected(),
  });

  const page = browser.newPage();
  const res = page.goto('https://google.com');

  sleep(20); // Force quit the browser process now

  check(browser, {
    'should be connected before ending iteration': browser.isConnected(),
  });

  // Disconnect from the browser instance.
  browser.close();
}

I was expecting the final 'should be connected before ending iteration' to fail since the browser process was killed and therefore there shouldn't be a valid connection still open.

Please remember to update the k6-docs and remove reference to this issue (look for <BWIPT id="453"/> and xk6-browser/issues/453).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions