Getting a panic error in test after clicking "Place order" button

I’m testing completed checkouts on a WooCommerce powered website (you can visit the example website by reviewing the script, linked at the bottom).

Had difficulty getting k6 to target the embedded iframes of the Braintree checkouts section, but finally cleared that hurdle.

The problem is after interacting with those two iframes, and then clicking on the Place order button (outside of those iframes) the test crashes within a couple seconds of that. I’ve tested different orders of operation to isolate exactly when the crash is happening (right after the page.screenshot on line 186 of my script).

I feel like the issue is that k6 is losing the context of the main page itself because of the iframe interactions but I can’t figure out a way to get it to not crash.

Here is the panic:

panic: GoError: dispose: disposing element with ID -1220096293751216353.29.1: Cannot find context with specified id (-32000)

Can’t embed the full trace because it’s seeing all the github mentions as URLs and I’m only allowed to post two apparently.

Link to the current script: https://raw.githubusercontent.com/gridpane-patrick/loadwoo/main/better_than_nothing.js

Hi @patricka1b8,

Apologies for the delay in getting back to you!

I’ve tried your script and at the moment I can’t seem to get past line 169 (const iframeHandle2 = page.waitForSelector('iframe[id*="braintree-hosted-field-expirationDate"]');), and it eventually times out looking for that selector. Do you know of anything has changed on your site?

Cheers,
Ankur

Ankur, thanks so much for getting back to me!

Yes, because we were completely stalled we had to switch back to doing only a COD checkout within WooCommerce. I have switched it back to Braintree so you should be able to retest. Thanks! Let me know if there is anything I can do to help.

Hi @patricka1b8,

Ok, now it’s progressed to line 162 (const field1 = frame.waitForSelector("input[name='credit-card-number']");) but seems to be waiting indefinitely there (which isn’t good either).

Cheers,
Ankur

I’m running the same test and I’m getting the kernel panic…

panic: GoError: dispose: disposing element with ID -2409315292900353541.29.1: Cannot find context with specified id (-32000)

running (00m47.8s), 20/20 VUs, 0 complete and 0 interrupted iterations

Could this be because I’m on a Mac/ARM ?

I will try to run this again on an Ubuntu 22.04 environment.

I’m taking a look at this. This might take me sometime but I’ll give you an update here.

There are two fixes to get your script to work. Both changes are currently in the following PRs:

  1. Fix execution context setting for iframes by ankur22 · Pull Request #1254 · grafana/xk6-browser · GitHub
  2. Investigate dispose context canceled by ankur22 · Pull Request #1261 · grafana/xk6-browser · GitHub

When combined I was able to run the test successfully with no errors or test aborts.

I’m hoping this will be part of the next release in the coming month.

Hi @ankur, I was waiting for these fixes, but still get similar error:

"panic: GoError: attaching iframe: attaching iframe target ID 336736BF1A0F9C59453A3471915510B1 to session ID B708E7301EF5DC72D9EDA91919296A0D: getting browser window ID: No web contents for the given target id (-32000)

goroutine 160 [running]:
go.k6.io/k6/js/common.Throw(...)
	go.k6.io/k6/js/common/util.go:20
github.com/grafana/xk6-browser/k6ext.Panic.func1(0xc002574008, {0xc0022faaa0?, 0x1ba1198?, 0xc001b5e080?})
	github.com/grafana/xk6-browser@v1.4.3/k6ext/panic.go:35 +0x74
github.com/grafana/xk6-browser/k6ext.sharedPanic({0x1bbc2c8, 0xc000d4ae10}, 0xc00311dc80, {0xc0022faaa0, 0x2, 0x2})
	github.com/grafana/xk6-browser@v1.4.3/k6ext/panic.go:64 +0x274
github.com/grafana/xk6-browser/k6ext.Panic({0x1bbc2c8?, 0xc000d4ae10?}, {0x180287d?, 0x29c6b40?}, {0xc0022faaa0?, 0xc00311dd00?, 0xc00311de08?})
	github.com/grafana/xk6-browser@v1.4.3/k6ext/panic.go:37 +0x5a
github.com/grafana/xk6-browser/common.(*FrameSession).onAttachedToTarget(0xc0014a7a20, 0xc0022fa4a0)
	github.com/grafana/xk6-browser@v1.4.3/common/frame_session.go:955 +0x671
github.com/grafana/xk6-browser/common.(*FrameSession).initEvents.func1()
	github.com/grafana/xk6-browser@v1.4.3/common/frame_session.go:279 +0x238
created by github.com/grafana/xk6-browser/common.(*FrameSession).initEvents in goroutine 148
	github.com/grafana/xk6-browser@v1.4.3/common/frame_session.go:220 +0x19b`

I run the tests in github actions on image: grafana/k6:master-with-browser and with options: --rm -i -v ${{ github.workspace }}:/app -w /app --network host -e K6_BROWSER_ENABLED=true --user root

It run fine when run locally with headed mode.

The fixes (PRs #1254 & #1261) are in main and will be in the latest release of k6 which is imminant.

Unfortunately I’ve completely overlooked the original error:

panic: GoError: dispose: disposing element with ID -1220096293751216353.29.1: Cannot find context with specified id (-32000)

This error doesn’t surface when working in headful mode and with the fixes:

K6_BROWSER_HEADLESS=false k6 run test.js

I’m now looking into the original issue, which you can track in Cannot find context with specified id (-32000) · Issue #1144 · grafana/xk6-browser · GitHub. Apologies for the misunderstanding and the delay.

Best,
Ankur

We think we have a viable fix for this issue which you can find here: Fix cannot find context error on `Dispose` by ankur22 · Pull Request #1291 · grafana/xk6-browser · GitHub. It has been merged in and will make the next release (v0.51.0) of k6, which should be released very soon.

Hello @ankur, i see the same error with my k6-browser script. When i ran with headless=false it worked perfect. But in headless mode it’s throwing panic error (panic: GoError: attaching iframe: attaching iframe target ID 225D1C79A0FF66C9E9A4E80CC970216C to session ID E461CF6D2436F061CDF233903EC34485: getting browser window ID: No web contents for the given target id (-32000)rrupted iterations)

FYI, i’m using latest version of k6 (k6 v0.51.0 (go1.22.3, darwin/arm64)) which intern using xk6-browser@v1.5.1

1 Like

@ankur I’m getting something similar on my end too. When running my test script in no-headless config everything works fine, but when running the test script in headless config this error halts test execution

panic: GoError: attaching iframe: attaching iframe target ID D1EEEDA5F1A09832DFA76BEDF0900053 to session ID 343164C61E5BFBE47C8129A6F3458395: getting browser window ID: No web contents for the given target id (-32000)

This is the stack trace

go.k6.io/k6/js/common.Throw(...)
        go.k6.io/k6/js/common/util.go:17
github.com/grafana/xk6-browser/k6ext.Panic.func1(0x140001e6008, {0x14001d9c140?, 0x103ee2301?, 0x1400049c5d8?})
        github.com/grafana/xk6-browser@v1.6.0/k6ext/panic.go:35 +0x7c
github.com/grafana/xk6-browser/k6ext.sharedPanic({0x104214bb0, 0x14000365220}, 0x140005a5c70, {0x14001d9c140, 0x2, 0x2})
        github.com/grafana/xk6-browser@v1.6.0/k6ext/panic.go:64 +0x20c
github.com/grafana/xk6-browser/k6ext.Panic({0x104214bb0?, 0x14000365220?}, {0x1039f40c1?, 0x1050b3980?}, {0x14001d9c140?, 0x14001639d00?, 0x140005a5df8?})
        github.com/grafana/xk6-browser@v1.6.0/k6ext/panic.go:37 +0x58
github.com/grafana/xk6-browser/common.(*FrameSession).onAttachedToTarget(0x14001399ce0, 0x14000fec860)
        github.com/grafana/xk6-browser@v1.6.0/common/frame_session.go:974 +0x558
github.com/grafana/xk6-browser/common.(*FrameSession).initEvents.func1()
        github.com/grafana/xk6-browser@v1.6.0/common/frame_session.go:283 +0x1ac
created by github.com/grafana/xk6-browser/common.(*FrameSession).initEvents in goroutine 160
        github.com/grafana/xk6-browser@v1.6.0/common/frame_session.go:224 +0x180

ENV: k6 v0.52.0 (go1.22.4, darwin/arm64)

Hi @rdt.one

We have an issue on GitHub Panic on attaching iframe when getting browser window ID · Issue #1224 · grafana/xk6-browser · GitHub that could be used for tracking it’s resolution

Hope that answers

Cheers!

2 Likes