Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ankur22 opened this issue Jul 12, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@ankur22
Copy link
Collaborator

ankur22 commented Jul 12, 2022

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).

@ankur22 ankur22 added the bug Something isn't working label Jul 12, 2022
@inancgumus
Copy link
Member

inancgumus commented Jul 12, 2022

Have you tried it without a promise (without Browser.on)? If you haven't, we might so we can see if it's the on method or the isConnected method.

@ankur22
Copy link
Collaborator Author

ankur22 commented Jul 12, 2022

Have you tried it without a promise (without Browser.on)? If you haven't, we might so we can see if it's the on method or the isConnected method.

Good point. I've tested it without calling browser.on and it still exhibits the incorrect behaviour. I will update the script above to avoid any confusion.

@inancgumus
Copy link
Member

@ankur22 Is this still relevant since we manage the browser processes?

@ankur22
Copy link
Collaborator Author

ankur22 commented Nov 30, 2023

Good point, let's close this 🎉

@ankur22 ankur22 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants