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

Investigate Uncaught (in promise) when evaluating JS: execution context changed #973

Closed
Tracked by #1138
ankur22 opened this issue Jul 13, 2023 · 2 comments
Closed
Tracked by #1138
Assignees
Labels
bug Something isn't working next Might be eligible for the next planning (not guaranteed!) remote remote browser related ux
Milestone

Comments

@ankur22
Copy link
Collaborator

ankur22 commented Jul 13, 2023

While running the following test script against a remote chrome instance:

import { check } from 'k6';
import { browser } from 'k6/experimental/browser';

export const options = {
  scenarios: {
    ui: {
      executor: 'shared-iterations',
      vus: 5,
      iterations: 1000,
      maxDuration: '40m',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
  thresholds: {
    checks: ["rate==1.0"]
  }
}

export default async function () {
  const context = browser.newContext();
  const page = context.newPage();

  try {
    // Goto front page, find login link and click it
    await page.goto('https://test.k6.io/', { waitUntil: 'networkidle' });
    await Promise.all([
      page.waitForNavigation(),
      page.locator('a[href="/my_messages.php"]').click(),
    ]);
    // Enter login credentials and login
    page.locator('input[name="login"]').type('admin');
    page.locator('input[name="password"]').type('123');
    // We expect the form submission to trigger a navigation, so to prevent a
    // race condition, setup a waiter concurrently while waiting for the click
    // to resolve.
    await Promise.all([
      page.waitForNavigation(),
      page.locator('input[type="submit"]').click(),
    ]);
    check(page, {
      'header': page.locator('h2').textContent() == 'Welcome, admin!',
    });
  } finally {
    page.close();
  }
}

I encountered the following error:

Uncaught (in promise) GoError: evaluating JS: execution context changed; most likely because of a navigation
	at github.com/grafana/xk6-browser/api.Page.Close-fm (native)
	at file:///tmp/POjeov/script.js:48:4(89)
 executor=shared-iterations scenario=ui

This was unexpected since this script seems to have all the necessary actions in place to avoid an issue when a navigation occurs. Replicate and resolve this issue.

Test run id: 154442

@ankur22 ankur22 added bug Something isn't working ux labels Jul 13, 2023
@ankur22 ankur22 added this to the v0.11.0 milestone Jul 13, 2023
@ankur22 ankur22 added the remote remote browser related label Jul 17, 2023
@ankur22
Copy link
Collaborator Author

ankur22 commented Jul 24, 2023

Could this also be related to #970 (comment)?

@inancgumus inancgumus added the next Might be eligible for the next planning (not guaranteed!) label Nov 30, 2023
@inancgumus
Copy link
Member

Closed by #1219.

@inancgumus inancgumus self-assigned this Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next Might be eligible for the next planning (not guaranteed!) remote remote browser related ux
Projects
None yet
Development

No branches or pull requests

2 participants