Out of the blue k6 is throwing panic

We use k6 very heavily in our workflow and run tests every few hours. Out of the blue all our builds are failing in the last 2 hours and we are getting this error. This is not easy to debug as it’s not coming from our code. Even the simplest of script is throwing this panic error. There is no code change in our side and we are wondering if you’re aware of this issue.

command - k6 run <path_to_scirpt>

   github.com/dop251/goja.(*Runtime).RunProgram.func1(0xc0052e57f0)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/runtime.go:1206 +0x95
panic(0x1dffea0, 0xc003e4f218)
	runtime/panic.go:965 +0x1b9
github.com/dop251/goja.(*vm).try.func1(0xc0013b8a00, 0x0, 0xc0052e56a0, 0x0, 0x0, 0x0, 0xc0052e5738)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/vm.go:505 +0xc1d
panic(0x1dffea0, 0xc003e4f218)
	runtime/panic.go:965 +0x1b9
github.com/dop251/goja.AssertFunction.func1.1(0xc0052e4d88)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/runtime.go:2090 +0x95
panic(0x1dffea0, 0xc003e4f218)
	runtime/panic.go:965 +0x1b9
github.com/dop251/goja.(*vm).try.func1(0xc0013b8a00, 0x1, 0xc0052e4c38, 0x3, 0x0, 0x1, 0xc0052e4cd0)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/vm.go:505 +0xc1d
panic(0x1dffea0, 0xc003e4f218)
	runtime/panic.go:965 +0x1b9
go.k6.io/k6/loader.cdnjs(0x211dd80, 0xc0008dd0a0, 0xc0004f42a0, 0x19, 0xc00298fc50, 0x3, 0x3, 0x3, 0x1e41ba0, 0x1, ...)
	go.k6.io/k6/loader/cdnjs.go:76 +0x6b7
go.k6.io/k6/loader.resolveUsingLoaders(0x211dd80, 0xc0008dd0a0, 0xc0004f42a0, 0x19, 0x1, 0x0, 0x0)
	go.k6.io/k6/loader/loader.go:247 +0x97
go.k6.io/k6/loader.Load(0x211dd80, 0xc0008dd0a0, 0xc0008ed3e0, 0xc0047fb290, 0xc0004f42a0, 0x19, 0x0, 0x1d88a80, 0xc0052e42e8)
	go.k6.io/k6/loader/loader.go:210 +0x8ed
go.k6.io/k6/js.(*InitContext).requireFile(0xc002262000, 0xc0004f42a0, 0x19, 0x0, 0x0, 0x0, 0x0)
	go.k6.io/k6/js/initcontext.go:172 +0x805
go.k6.io/k6/js.(*InitContext).Require(0xc002262000, 0xc0004f42a0, 0x19, 0x0, 0x0)
	go.k6.io/k6/js/initcontext.go:134 +0xb1
reflect.Value.call(0x1ce9f60, 0xc0013c4ec0, 0x13, 0x1ebcf50, 0x4, 0xc0046fd338, 0x1, 0x1, 0xc0052e4710, 0x100fa38, ...)
	reflect/value.go:476 +0x8e7
reflect.Value.Call(0x1ce9f60, 0xc0013c4ec0, 0x13, 0xc0046fd338, 0x1, 0x1, 0xc000010438, 0x0, 0x0)
	reflect/value.go:337 +0xb9
github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1(0x211a308, 0x2a6dc00, 0xc0048142e0, 0x1, 0x1ba, 0x10155fd, 0xc00129b771)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/runtime.go:1701 +0x3be
github.com/dop251/goja.(*vm)._nativeCall(0xc0013b8a00, 0xc0020de3c0, 0x1)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/vm.go:2357 +0x266
github.com/dop251/goja.call.exec(0x1, 0xc0013b8a00)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/vm.go:2329 +0x776
github.com/dop251/goja.(*vm).run(0xc0013b8a00)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/vm.go:395 +0x94
github.com/dop251/goja.(*funcObject).call(0xc00310dee0, 0x2119ab8, 0xc001d00090, 0xc0016873e0, 0x2, 0x2, 0x0, 0x0, 0x0, 0x2)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/func.go:161 +0x225
github.com/dop251/goja.(*funcObject).Call(...)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/func.go:129
github.com/dop251/goja.AssertFunction.func1.2()
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/runtime.go:2095 +0x96
github.com/dop251/goja.(*vm).try(0xc0013b8a00, 0xc0052e4cf0, 0x0)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/vm.go:511 +0x188
github.com/dop251/goja.AssertFunction.func1(0x2119ab8, 0xc001d00090, 0xc0016873e0, 0x2, 0x2, 0x0, 0x0, 0x0, 0x0)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/runtime.go:2094 +0x10b
go.k6.io/k6/js.(*InitContext).requireFile(0xc002262000, 0xc00129b600, 0x10, 0x0, 0x0, 0x0, 0x0)
	go.k6.io/k6/js/initcontext.go:195 +0x61f
go.k6.io/k6/js.(*InitContext).Require(0xc002262000, 0xc00129b600, 0x10, 0x0, 0x0)
	go.k6.io/k6/js/initcontext.go:134 +0xb1
reflect.Value.call(0x1ce9f60, 0xc0013c4ec0, 0x13, 0x1ebcf50, 0x4, 0xc001d2ce58, 0x1, 0x1, 0xc0023cd2c8, 0x100fa38, ...)
	reflect/value.go:476 +0x8e7
reflect.Value.Call(0x1ce9f60, 0xc0013c4ec0, 0x13, 0xc001d2ce58, 0x1, 0x1, 0xc0001ab390, 0x0, 0x0)
	reflect/value.go:337 +0xb9
github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1(0x211a308, 0x2a6dc00, 0xc0022803a0, 0x1, 0x6, 0x10155fd, 0xc00129b771)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/runtime.go:1701 +0x3be
github.com/dop251/goja.(*vm)._nativeCall(0xc0013b8a00, 0xc0020de3c0, 0x1)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/vm.go:2357 +0x266
github.com/dop251/goja.call.exec(0x1, 0xc0013b8a00)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/vm.go:2329 +0x776
github.com/dop251/goja.(*vm).run(0xc0013b8a00)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/vm.go:395 +0x94
github.com/dop251/goja.(*vm).try(0xc0013b8a00, 0xc0023cd7a0, 0x0)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/vm.go:511 +0x188
github.com/dop251/goja.(*vm).runTry(...)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/vm.go:516
github.com/dop251/goja.(*Runtime).RunProgram(0xc00255c000, 0xc001d57260, 0x0, 0x0, 0x0, 0x0)
	github.com/dop251/goja@v0.0.0-20210427212725-462d53687b0d/runtime.go:1221 +0x128
go.k6.io/k6/js.(*Bundle).instantiate(0xc0000da580, 0x211dd80, 0xc0008dd0a0, 0xc00255c000, 0xc002262000, 0x0, 0x0, 0x0)
	go.k6.io/k6/js/bundle.go:319 +0x7fc
go.k6.io/k6/js.NewBundle(0x211dd80, 0xc0008dd0a0, 0xc000b81f60, 0xc0008ed3e0, 0x1, 0x1ec1fd7, 0x8, 0x0, 0xc0008ed7d0, 0x0, ...)
	go.k6.io/k6/js/bundle.go:100 +0x458
go.k6.io/k6/js.New(0xc0008dd0a0, 0xc000b81f60, 0xc0008ed3e0, 0x1, 0x1ec1fd7, 0x8, 0x0, 0xc0008ed7d0, 0x0, 0x0, ...)
	go.k6.io/k6/js/runner.go:76 +0xa7
go.k6.io/k6/cmd.newRunner(0xc0008dd0a0, 0xc000b81f60, 0x1ebc816, 0x2, 0xc0008ed3e0, 0x1, 0x1ec1fd7, 0x8, 0x0, 0xc0008ed7d0, ...)
	go.k6.io/k6/cmd/run.go:418 +0x174
go.k6.io/k6/cmd.newRunner(0xc0008dd0a0, 0xc000b81f60, 0x0, 0x0, 0xc0008ed3e0, 0x1, 0x1ec1fd7, 0x8, 0x0, 0xc0008ed7d0, ...)
	go.k6.io/k6/cmd/run.go:416 +0x61d
go.k6.io/k6/cmd.getRunCmd.func1(0xc0008e1180, 0xc0000d9bb0, 0x1, 0x1, 0x0, 0x0)
	go.k6.io/k6/cmd/run.go:127 +0x6d0
github.com/spf13/cobra.(*Command).execute(0xc0008e1180, 0xc0000d9b90, 0x1, 0x1, 0xc0008e1180, 0xc0000d9b90)
	github.com/spf13/cobra@v1.1.3/command.go:852 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc0008db400, 0xc0001f3df0, 0xc, 0xc)
	github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.1.3/command.go:897
go.k6.io/k6/cmd.Execute()
	go.k6.io/k6/cmd/root.go:198 +0x56b
main.main()
	go.k6.io/k6/main.go:28 +0x25

Which version of k6 are you using and what’s your OS?

I was using k6 ( 31) and upgraded ( 32 ) locally. I am seeing this issue on both versions. Our CI builds uses K6 ( 31 ). I am using MacOS Catalina Version 10.15.5 locally. @ned

Judging from that part of the panic, it it some sort of a problem with the cdnjs loader. Please share which libraries from cdnjs you import, so we may try to reproduce the problem. And until it’s fixed, I suggest downloading them and importing them locally instead of directly from cdnjs.

import moment from "cdnjs.com/libraries/moment.js/2.18.1";
import faker from "cdnjs.com/libraries/Faker";
import { URL } from "https://jslib.k6.io/url/1.0.0/index.js";

import faker from "https://raw.githubusercontent.com/Marak/faker.js/e0a928f53aa2e83965bcf9400aac1ea9f1e7eb7e/dist/faker.min.js";
We are trying out this import and it seems to work.

I created an issue about this: panic when importing modules from cdnjs · Issue #2037 · k6io/k6 · GitHub

It actually seems like the faker library was deleted from cdnjs or something like that, moment.js seems to work fine :confused: :man_shrugging: In any case, k6 definitely shouldn’t panic.

1 Like