Panic error when using "page.goto()" with xk6-browser

I am currently performing E2E testing on RHEL8 linux using the latest versions of k6 and xk6-browser, slowly ramping up the number of VUs to 50. However sometimes, page.goto() will cause this panic error to happen, and crash the execution.

 panic: interface conversion: interface {} is nil, not *common.NavigationEvent
goroutine 25 [running]:
runtime/debug.Stack()
scenarioruntime/debug/stack.go:24 +0x65
go.k6.io/k6/js/common.RunWithPanicCatching.func1()
        go.k6.io/k6@v0.39.0/js/common/util.go:102 +0x191
panic({0x121f440, 0xc009b17ce0})
        runtime/panic.go:838 +0x207
github.com/dop251/goja.AssertFunction.func1.1()
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/runtime.go:2305 +0x6e
panic({0x121f440, 0xc009b17ce0})
        runtime/panic.go:838 +0x207
github.com/dop251/goja.(*vm).try.func1()
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:537 +0x635
panic({0x121f440, 0xc009b17ce0})
        runtime/panic.go:838 +0x207
github.com/dop251/goja.AssertFunction.func1.1()
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/runtime.go:2305 +0x6e
panic({0x121f440, 0xc009b17ce0})
        runtime/panic.go:838 +0x207
github.com/dop251/goja.(*vm).try.func1()
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:537 +0x635
panic({0x121f440, 0xc009b17ce0})
        runtime/panic.go:838 +0x207
github.com/dop251/goja.(*vm).try.func1()
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:537 +0x635
panic({0x121f440, 0xc009b17ce0})
        runtime/panic.go:838 +0x207
github.com/grafana/xk6-browser/common.(*FrameManager).NavigateFrame(0xc0019c4270, 0xc00688b880, {0xc001b72d60, 0x1d}, {0x169bea8, 0xc00b0cd050})
        github.com/grafana/xk6-browser@v0.4.0/common/frame_manager.go:664 +0x1405
github.com/grafana/xk6-browser/common.(*Frame).Goto(0xc00688b880, {0xc001b72d60?, 0x13c0f8a?}, {0x169bea8?, 0xc00b0cd050?})
        github.com/grafana/xk6-browser@v0.4.0/common/frame.go:1057 +0x45
github.com/grafana/xk6-browser/common.(*Page).Goto(0xc00343d4a0, {0xc001b72d60, 0x1d}, {0x169bea8, 0xc00b0cd050})
        github.com/grafana/xk6-browser@v0.4.0/common/page.go:566 +0x142
reflect.Value.call({0x13b08c0?, 0xc00343d4a0?, 0x7f6ee3ee6878?}, {0x13ba8bf, 0x4}, {0xc00b0cd0b0, 0x2, 0xc006000048?})
        reflect/value.go:556 +0x845
reflect.Value.Call({0x13b08c0?, 0xc00343d4a0?, 0xc00b0cd050?}, {0xc00b0cd0b0, 0x2, 0x2})
        reflect/value.go:339 +0xbf
github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1({{0x169bea8, 0xc0013838c0}, {0xc000d57ce0, 0x2, 0x26}})
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/runtime.go:1891 +0x1c5
github.com/dop251/goja.(*vm)._nativeCall(0xc0019b2000, 0xc010375e00, 0x2)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:2737 +0x217
github.com/dop251/goja.call.exec(0x7?, 0xc0019b2000)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:2709 +0x95b
github.com/dop251/goja.(*vm).run(0xc0019b2000)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:408 +0x8b
github.com/dop251/goja.(*vm).try(0xc010375720?, 0xc00250efd0?)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:545 +0x176
github.com/dop251/goja.(*vm).runTry(...)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:550
github.com/dop251/goja.try.exec({0x3?, 0x0?}, 0xc0019b2000)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:3640 +0x6c
github.com/dop251/goja.(*vm).run(0xc0019b2000)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:408 +0x8b
github.com/dop251/goja.(*baseJsFuncObject)._call(0xc00eb634a0, {{0x169c6f8, 0x21eed40}, {0x0, 0x0, 0x0}}, {0x0?, 0x0}, {0x169c6f8, 0x21eed40})
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/func.go:193 +0x3ff
github.com/dop251/goja.(*baseJsFuncObject).call(...)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/func.go:203
github.com/dop251/goja.(*baseJsFuncObject).Call(0x403be6?, {{0x169c6f8, 0x21eed40}, {0x0, 0x0, 0x0}})
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/func.go:156 +0xc7
github.com/dop251/goja.AssertFunction.func1.2()
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/runtime.go:2310 +0x74
github.com/dop251/goja.(*vm).try(0x98efc6?, 0xc003a745b0?)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:545 +0x176
github.com/dop251/goja.AssertFunction.func1({0x169c6f8?, 0x21eed40?}, {0x0?, 0xc001426a40?, 0xb?})
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/runtime.go:2309 +0x10c
go.k6.io/k6/js/modules/k6.(*K6).Group(0xc002b76250, {0xc00cfb99e0, 0x9}, 0xc00644c810)
        go.k6.io/k6@v0.39.0/js/modules/k6/k6.go:138 +0x1f4
reflect.Value.call({0x1202920?, 0xc002b76280?, 0x7f6ee3ee6878?}, {0x13ba8bf, 0x4}, {0xc00b0cc2a0, 0x2, 0xc006001178?})
        reflect/value.go:556 +0x845
reflect.Value.Call({0x1202920?, 0xc002b76280?, 0xc00b0cc210?}, {0xc00b0cc2a0, 0x2, 0x2})
        reflect/value.go:339 +0xbf
github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1({{0x169c6f8, 0x21eed40}, {0xc000d57c80, 0x2, 0x2c}})
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/runtime.go:1891 +0x1c5
github.com/dop251/goja.(*vm)._nativeCall(0xc0019b2000, 0xc010374000, 0x2)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:2737 +0x217
github.com/dop251/goja.call.exec(0x4?, 0xc0019b2000)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:2709 +0x95b
github.com/dop251/goja.(*vm).run(0xc0019b2000)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:408 +0x8b
github.com/dop251/goja.(*baseJsFuncObject)._call(0xc001ad04d0, {{0x169c6f8, 0x21eed40}, {0xc002416a60, 0x1, 0x1}}, {0x0?, 0x0}, {0x169c6f8, 0x21eed40})
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/func.go:193 +0x3ff
github.com/dop251/goja.(*baseJsFuncObject).call(...)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/func.go:203
github.com/dop251/goja.(*baseJsFuncObject).Call(0x0?, {{0x169c6f8, 0x21eed40}, {0xc002416a60, 0x1, 0x1}})
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/func.go:156 +0xc7
github.com/dop251/goja.AssertFunction.func1.2()
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/runtime.go:2310 +0x74
github.com/dop251/goja.(*vm).try(0xc003036830?, 0x40d325?)
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/vm.go:545 +0x176
github.com/dop251/goja.AssertFunction.func1({0x169c6f8?, 0x21eed40?}, {0xc002416a60?, 0x1?, 0x1?})
        github.com/dop251/goja@v0.0.0-20220516123900-4418d4575a41/runtime.go:2309 +0x10c
go.k6.io/k6/js.(*VU).runFn.func1.1()
        go.k6.io/k6@v0.39.0/js/runner.go:800 +0x43
go.k6.io/k6/js/eventloop.(*EventLoop).Start(0xc001ac60f0, 0xc002db5590)
        go.k6.io/k6@v0.39.0/js/eventloop/eventloop.go:112 +0x177
go.k6.io/k6/js.(*VU).runFn.func1()
        go.k6.io/k6@v0.39.0/js/runner.go:799 +0xee
go.k6.io/k6/js/common.RunWithPanicCatching({0x169d7c0?, 0xc000252bd0?}, 0x8?, 0x90?)
        go.k6.io/k6@v0.39.0/js/common/util.go:106 +0x87
go.k6.io/k6/js.(*VU).runFn(0xc002d85a40, {0x16939e8, 0xc00103acc0}, 0xe0?, 0xc001b2f7a0, 0xc002416a50, {0xc002416a60, 0x1, 0x1})
        go.k6.io/k6@v0.39.0/js/runner.go:798 +0x2a5
go.k6.io/k6/js.(*ActiveVU).RunOnce(0xc000fee500)
        go.k6.io/k6@v0.39.0/js/runner.go:750 +0x40f
go.k6.io/k6/lib/executor.getIterationRunner.func1({0x16939e8, 0xc001b528c0}, {0x16899c0?, 0xc000fee500?})
        go.k6.io/k6@v0.39.0/lib/executor/helpers.go:144 +0x64
go.k6.io/k6/lib/executor.(*vuHandle).runLoopsIfPossible(0xc001fca2d0, 0xc001d68018)
        go.k6.io/k6@v0.39.0/lib/executor/vu_handle.go:225 +0xf3
created by go.k6.io/k6/lib/executor.(*rampingVUsRunState).runLoopsIfPossible
        go.k6.io/k6@v0.39.0/lib/executor/ramping_vus.go:633 +0xf5

Goja stack:
native

Is there a way to prevent this error, or at the least catch it so it does not interrupt the whole execution?
Thank you

Hi there, welcome to the forum :slight_smile:

This is a bug in xk6-browser and shouldn’t happen. It’s part of a series of known stability issues we’re currently working on resolving. See issue #427.

Unfortunately there’s currently no way for you to work around it. Running with less VUs should generally help, but these kinds of issues can popup even then.

If you don’t mind, could you create a new issue on GitHub for this? Please include your OS and xk6-browser versions (I’m assuming it’s v0.4.0, but mention it there), this stack trace, and some instructions to reproduce it with a small script. Even if the issue is intermittent it would help having a script to test with. Thanks!