grafana / xk6-loki

k6 extension for Loki
Apache License 2.0
38 stars 18 forks source link

k6 panic if pushParameterized minSize>maxSize #50

Open mstoykov opened 2 years ago

mstoykov commented 2 years ago

Running

import loki from "k6/x/loki"

const conf = new loki.Config("https://somewhere.com", 20000, 1.0, { one: 1 });
const client = new loki.Client(conf);

export default function() {
  client.pushParameterized(1, 1000, 1000);
};

panics. But it should likely just be a js exception.

mstoykov commented 2 years ago

Stacktrace:

ERRO[0000] panic: invalid argument to Intn
goroutine 81 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x65
go.k6.io/k6/js/common.RunWithPanicCatching.func1()
        go.k6.io/k6@v0.40.1-0.20221020144551-8a74171c8b43/js/common/util.go:82 +0x191
panic({0x150ee40, 0x1ab48d0})
        runtime/panic.go:884 +0x212
github.com/dop251/goja.(*Runtime).runWrapped.func1()
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/runtime.go:2437 +0xdc
panic({0x150ee40, 0x1ab48d0})
        runtime/panic.go:884 +0x212
github.com/dop251/goja.(*vm).try.func1()
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/vm.go:626 +0x70f
panic({0x150ee40, 0x1ab48d0})
        runtime/panic.go:884 +0x212
math/rand.(*Rand).Intn(0xc0005e4100?, 0xf0?)
        math/rand/rand.go:168 +0x65
math/rand.Intn(...)
        math/rand/rand.go:337
github.com/grafana/xk6-loki.(*Client).newBatch(0xc0024bfda0, 0x0?, 0x1, 0x3e8, 0x3e8)
        github.com/grafana/xk6-loki@v0.0.0-20221027072901-25f517ea76e9/batch.go:157 +0x168
github.com/grafana/xk6-loki.(*Client).PushParameterized(_, _, _, _)
        github.com/grafana/xk6-loki@v0.0.0-20221027072901-25f517ea76e9/client.go:239 +0x1a5
reflect.Value.call({0x1708ca0?, 0xc0024bfda0?, 0x7f8101687108?}, {0x1788ffc, 0x4}, {0xc00077dcc0, 0x3, 0xc00062d068?})
        reflect/value.go:584 +0x8c5
reflect.Value.Call({0x1708ca0?, 0xc0024bfda0?, 0xc001f64ff0?}, {0xc00077dcc0?, 0xc0004d2080?, 0x1708ca0?})
        reflect/value.go:368 +0xbc
github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1({{0x1adcc78, 0xc001e205a0}, {0xc0009c4550, 0x3, 0xb}})
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/runtime.go:1980 +0x1da
github.com/dop251/goja.(*vm)._nativeCall(0xc0000bfb00, 0xc0001ac3c0, 0x3)
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/vm.go:3233 +0x1e3
github.com/dop251/goja.call.exec(0x11?, 0xc0000bfb00)
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/vm.go:3205 +0x14d
github.com/dop251/goja.(*vm).run(0xc0000bfb00)
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/vm.go:495 +0x8b
github.com/dop251/goja.(*baseJsFuncObject)._call(0xc0001ab500, {0xc000847900?, 0x1, 0x0?}, {0x0?, 0x0}, {0x1add5f8?, 0x28bd6e0?})
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/func.go:318 +0x3f8
github.com/dop251/goja.(*baseJsFuncObject).call(...)
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/func.go:328
github.com/dop251/goja.(*baseJsFuncObject).Call(0x203000?, {{0x1add5f8, 0x28bd6e0}, {0xc000847900, 0x1, 0x1}})
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/func.go:280 +0xa5
github.com/dop251/goja.AssertFunction.func1.1()
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/runtime.go:2397 +0x74
github.com/dop251/goja.(*vm).try(0xc0000bfb00, 0x400?)
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/vm.go:634 +0x18a
github.com/dop251/goja.(*Runtime).runWrapped(0xc00210d500, 0x8?)
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/runtime.go:2441 +0x7c
github.com/dop251/goja.AssertFunction.func1({0x1add5f8?, 0x28bd6e0?}, {0xc000847900?, 0x1?, 0x1?})
        github.com/dop251/goja@v0.0.0-20221003171542-5ea1285e6c91/runtime.go:2396 +0x92
go.k6.io/k6/js.(*VU).runFn.func2.1()
        go.k6.io/k6@v0.40.1-0.20221020144551-8a74171c8b43/js/runner.go:774 +0x43
go.k6.io/k6/js/eventloop.(*EventLoop).Start(0xc00077d4a0, 0xc001f559e0)
        go.k6.io/k6@v0.40.1-0.20221020144551-8a74171c8b43/js/eventloop/eventloop.go:171 +0x1b7
go.k6.io/k6/js.(*VU).runFn.func2()
        go.k6.io/k6@v0.40.1-0.20221020144551-8a74171c8b43/js/runner.go:773 +0xeb
go.k6.io/k6/js/common.RunWithPanicCatching({0x1ae2a20?, 0xc000a01100?}, 0x40f6e6?, 0x15a7560?)
        go.k6.io/k6@v0.40.1-0.20221020144551-8a74171c8b43/js/common/util.go:86 +0x87
go.k6.io/k6/js.(*VU).runFn(0xc0001ab5c0, {0x1ac6480, 0xc0020a53c0}, 0xc0?, 0xc000010960, 0xc0008478f0, {0xc000847900, 0x1, 0x1})
        go.k6.io/k6@v0.40.1-0.20221020144551-8a74171c8b43/js/runner.go:772 +0x28a
go.k6.io/k6/js.(*ActiveVU).RunOnce(0xc0020a5380)
        go.k6.io/k6@v0.40.1-0.20221020144551-8a74171c8b43/js/runner.go:717 +0x412
go.k6.io/k6/lib/executor.getIterationRunner.func1({0x1ac6528, 0xc001f55770}, {0x1ab7420?, 0xc0020a5380?})
        go.k6.io/k6@v0.40.1-0.20221020144551-8a74171c8b43/lib/executor/helpers.go:124 +0x64
go.k6.io/k6/lib/executor.PerVUIterations.Run.func5({0x1abdc88, 0xc0001ab5c0})
        go.k6.io/k6@v0.40.1-0.20221020144551-8a74171c8b43/lib/executor/per_vu_iterations.go:227 +0x40a
created by go.k6.io/k6/lib/executor.PerVUIterations.Run
        go.k6.io/k6@v0.40.1-0.20221020144551-8a74171c8b43/lib/executor/per_vu_iterations.go:240 +0xc29