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

Frame requestByID panics when initializing networking #986

Closed
3 tasks done
Tracked by #4236
inancgumus opened this issue Jul 31, 2023 · 8 comments
Closed
3 tasks done
Tracked by #4236

Frame requestByID panics when initializing networking #986

inancgumus opened this issue Jul 31, 2023 · 8 comments
Assignees
Labels
bug Something isn't working next Might be eligible for the next planning (not guaranteed!) remote remote browser related

Comments

@inancgumus
Copy link
Member

inancgumus commented Jul 31, 2023

Brief summary

There is a flaky bug in (*Frame).requestByID that happens while initializing (*NetworkManager).initEvents. The test run ID is 155045.

xk6-browser version

0fcdd36

OS

Linux

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Run the following script on a resource restricted platform several times as the issue is flaky.

The script
import { browser } from 'k6/experimental/browser'
import { check } from 'k6'

export const options = {
  scenarios: {
    browser: {
      executor: 'per-vu-iterations',
      maxDuration: '15m',
      vus: 5,
      iterations: 10,
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  }
}
export default async function () {
  const page = browser.newPage();

  try {
    // User journy in SPA application
    await page.goto('https://.../'); // TODO: change it to the otel app

    const productCard = page.locator('(//div[@data-cy="product-card"])[1]')
    productCard.click()

    const quantityOption = page.locator('[data-cy="product-quantity"]')
    quantityOption.selectOption('3')
    const addToCardBtn = page.locator('[data-cy="product-add-to-cart"]')
    addToCardBtn.click()

    check(page, {
      'cart item name': page => page.locator('//p[text()="National Park Foundation Explorascope"]').isVisible() === true,
      'cart item quantity': page => page.locator('//p[text()="3"]').isVisible() === true
    })

    // Check GH link to force another navigation
    await Promise.all([
      page.waitForNavigation(),
      page.locator('footer a').click(),
    ]);
    check(page, {
      'gh-author': page.locator(
        'div#repository-container-header span.author a'
      ).textContent().includes('open-telemetry'),
    });
  } finally {
    page.close();
  }
}

Expected behaviour

No panics.

Actual behaviour

goroutine 246996 [running]:
github.com/grafana/xk6-browser/common.(*Frame).requestByID(0xc0089428c0, {0xc009718454, 0x7})
	github.com/grafana/xk6-browser@v1.0.0-rc0.0.20230726091449-0fcdd3618f29/common/frame.go:365 +0x5a
github.com/grafana/xk6-browser/common.(*FrameManager).requestFailed(0xc001d700c0, 0xc0055d4640, 0x0)
	github.com/grafana/xk6-browser@v1.0.0-rc0.0.20230726091449-0fcdd3618f29/common/frame_manager.go:450 +0x4d7
github.com/grafana/xk6-browser/common.(*NetworkManager).onLoadingFailed(0xc008dd3ea0, 0xc007489200)
	github.com/grafana/xk6-browser@v1.0.0-rc0.0.20230726091449-0fcdd3618f29/common/network_manager.go:345 +0x116
github.com/grafana/xk6-browser/common.(*NetworkManager).handleEvents(0xc008dd3ea0, 0xc004206960)
	github.com/grafana/xk6-browser@v1.0.0-rc0.0.20230726091449-0fcdd3618f29/common/network_manager.go:318 +0x288
github.com/grafana/xk6-browser/common.(*NetworkManager).initEvents.func1()
	github.com/grafana/xk6-browser@v1.0.0-rc0.0.20230726091449-0fcdd3618f29/common/network_manager.go:301 +0x37
created by github.com/grafana/xk6-browser/common.(*NetworkManager).initEvents
	github.com/grafana/xk6-browser@v1.0.0-rc0.0.20230726091449-0fcdd3618f29/common/network_manager.go:300 +0x14d

Tasks

Preview Give feedback
  1. ankur22
  2. maintenance
    inancgumus
  3. inancgumus
@inancgumus inancgumus added bug Something isn't working remote remote browser related labels Jul 31, 2023
@DefCon-007
Copy link

Reproducible when multiple browser VUs are assigned i.e. multiple browser containers are initialised

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

ankur22 commented Feb 19, 2024

While taking a look at this discussion here, I looked through the code again and it does indeed seem that the issue lies on line 412 which would indicate that the original frameSession from line 408 was nil, or its networkManager were nil.

I think the best course of action is:

  1. Protect against NPD by ensuring that both the mainFrameSession and its networkManager are not nil, and log a warning when either of them are.
  2. Replicate the issue to diagnose exactly why we get into this state. I currently cannot see any reason for the mainFrameSession to be nil on a page. When a page is created, the mainFrame is also created, along with that the networkManager is also created. So how does a page end up with a nil mainFrame or how does the mainFrame end up with a nil networkManager?

@inancgumus
Copy link
Member Author

I agree that we need to first determine which one (or both) is nil. We can add a simple logger to determine 👍

@ankur22 ankur22 self-assigned this Feb 20, 2024
@ankur22
Copy link
Collaborator

ankur22 commented Feb 20, 2024

As a step towards understanding the root cause we've created #1220 to help us identify exactly which component is nil. We might be in a better position to find the root cause of the issue once we see the logs.

@ankur22 ankur22 removed their assignment Feb 20, 2024
@inancgumus
Copy link
Member Author

Closed by #1219.

@ankur22
Copy link
Collaborator

ankur22 commented Mar 7, 2024

We've seen more cases of this even after #1219. Reopening.

@ankur22 ankur22 reopened this Mar 7, 2024
@inancgumus
Copy link
Member Author

Happened in test run ID: 2480444 (prod).

@joanlopez
Copy link

Happened in test run ID: 2480444 (prod).

Another occurrence in test run ID: 2539482 (prod).

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug Something isn't working next Might be eligible for the next planning (not guaranteed!) remote remote browser related
Projects
None yet
Development

No branches or pull requests

4 participants