Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about async/await and subscribe() usage #12

Open
terradek opened this issue Sep 20, 2023 · 0 comments
Open

Question about async/await and subscribe() usage #12

terradek opened this issue Sep 20, 2023 · 0 comments

Comments

@terradek
Copy link

terradek commented Sep 20, 2023

Could you please tell me how to use subsctiber.subscribe()
I am facing with fails using this function, even with examples from the repository.
For example the test.js
Fails with the below error.
As I understand there are some issues with sleep(). Because it starts throwing these errors when 2 messages already received successfully.
But I don't understand where the sleep functions should be applied. And the other question, can I use async/await with the xk6-nats functions?

And one more question - is this possible to add some functionality to get stats from the nats server just like it was implemented in nats monitoring?

Thank you!

INFO[0002] {"1the message":{"raw":[49,116,104,101,32,109,101,115,115,97,103,101],"data":"1the message","topic":"test","header":{}}}  source=console
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
running panic: runtime error: invalid memory address or nil pointer dereference [recovered]
constantpanic: runtime error: invalid memory address or nil pointer dereference [recovered]5h0m0s  100000.00 iters/s
        panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xad1191]

goroutine 248 [running]:
github.com/dop251/goja.(*Runtime).runWrapped.func1()
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/runtime.go:2517 +0x185
panic({0x2b9ef20, 0x51abf80})
        runtime/panic.go:884 +0x213
github.com/dop251/goja.(*vm).handleThrow(0xc0031e0000, {0x2b9ef20, 0x51abf80})
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:788 +0x497
github.com/dop251/goja.(*vm).try.func1()
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:807 +0x45
panic({0x2b9ef20, 0x51abf80})
        runtime/panic.go:884 +0x213
github.com/dop251/goja.(*vm).handleThrow(0xc0031e0000, {0x2b9ef20, 0x51abf80})
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:788 +0x497
github.com/dop251/goja.(*vm).runTryInner.func1()
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:830 +0x45
panic({0x2b9ef20, 0x51abf80})
        runtime/panic.go:884 +0x213
github.com/dop251/goja.(*Runtime).runWrapped.func1()
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/runtime.go:2517 +0x185
panic({0x2b9ef20, 0x51abf80})
        runtime/panic.go:884 +0x213
github.com/dop251/goja.(*vm).handleThrow(0xc0031e0000, {0x2b9ef20, 0x51abf80})
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:788 +0x497
github.com/dop251/goja.(*vm).try.func1()
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:807 +0x45
panic({0x2b9ef20, 0x51abf80})
        runtime/panic.go:884 +0x213
github.com/dop251/goja.(*vm).handleThrow(0xc0031e0000, {0x2b9ef20, 0x51abf80})
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:788 +0x497
github.com/dop251/goja.(*vm).runTryInner.func1()
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:830 +0x45
panic({0x2b9ef20, 0x51abf80})
        runtime/panic.go:884 +0x213
github.com/dop251/goja.(*vm).run(0xc0031e0000)
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:579 +0xb1
github.com/dop251/goja.(*vm).runTryInner(0xc0031e0000?)
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:834 +0x70
github.com/dop251/goja.(*baseJsFuncObject).__call(0xc00468c7e0, {0xc002456fb0?, 0x1, 0x30?}, {0x0?, 0x0}, {0x0?, 0x0?})
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/func.go:426 +0x705
github.com/dop251/goja.(*baseJsFuncObject)._call(...)
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/func.go:442
github.com/dop251/goja.(*arrowFuncObject).Call(0x4043c5?, {{0x37116a8, 0x5228a60}, {0xc002456fb0, 0x1, 0x1}})
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/func.go:386 +0x57
github.com/dop251/goja.AssertFunction.func1.1()
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/runtime.go:2477 +0x77
github.com/dop251/goja.(*vm).try(0xc0031e0000, 0xc003a4a798)
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:811 +0x244
github.com/dop251/goja.(*Runtime).runWrapped(0xc000f00400, 0x7f8bdb46e358?)
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/runtime.go:2521 +0x7c
github.com/dop251/goja.AssertFunction.func1({0x37116a8?, 0x5228a60?}, {0xc002456fb0?, 0xc00302ca98?, 0x13?})
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/runtime.go:2476 +0x92
go.k6.io/k6/js/modules/k6.(*K6).Check(0xc000d8eca0, {0x3710ac8?, 0xc003548ab0}, {0x3710ac8, 0xc004ec0060}, {0x5228fc0, 0x0, 0x4d6cbe?})
        go.k6.io/k6@v0.46.0/js/modules/k6/k6.go:195 +0x3fe
reflect.Value.call({0x2b93e80?, 0xc000d8ecb0?, 0x7f8bdb6dbbf8?}, {0x30102b2, 0x4}, {0xc004ec01e0, 0x2, 0x0?})
        reflect/value.go:586 +0xb0b
reflect.Value.Call({0x2b93e80?, 0xc000d8ecb0?, 0xc004ec0060?}, {0xc004ec01e0?, 0xc002456e20?, 0x7f8bdb8388e8?})
        reflect/value.go:370 +0xbc
github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1({{0x37116a8, 0x5228a60}, {0xc001a7a4e0, 0x2, 0x12}})
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/runtime.go:2057 +0x3dc
github.com/dop251/goja.(*nativeFuncObject).vmCall(0xc0034cf500, 0xc0031e0000, 0x2)
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/func.go:559 +0x1af
github.com/dop251/goja.call.exec(0x11?, 0xc0031e0000)
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:3366 +0x6a
github.com/dop251/goja.(*vm).run(0xc0031e0000)
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:582 +0x62
github.com/dop251/goja.(*vm).runTryInner(0xc0031e0000?)
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:834 +0x70
github.com/dop251/goja.(*baseJsFuncObject).__call(0xc00107e620, {0xc00274b360?, 0x1, 0xc0036dd520?}, {0x0?, 0x0}, {0x0?, 0x0?})
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/func.go:426 +0x705
github.com/dop251/goja.(*baseJsFuncObject)._call(...)
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/func.go:442
github.com/dop251/goja.(*arrowFuncObject).Call(0xc00337f7c0?, {{0x37116a8, 0x5228a60}, {0xc00274b360, 0x1, 0x1}})
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/func.go:386 +0x57
github.com/dop251/goja.AssertFunction.func1.1()
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/runtime.go:2477 +0x77
github.com/dop251/goja.(*vm).try(0xc0031e0000, 0xc0036dd718)
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/vm.go:811 +0x244
github.com/dop251/goja.(*Runtime).runWrapped(0xc000f00400, 0x7f8bdb4c18b8?)
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/runtime.go:2521 +0x7c
github.com/dop251/goja.AssertFunction.func1({0x37116a8?, 0x5228a60?}, {0xc00274b360?, 0xc001b7a160?, 0xa9?})
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/runtime.go:2476 +0x92
github.com/dop251/goja.(*Runtime).wrapJSFunc.func1({0xc0010e8930, 0x1, 0x8?})
        github.com/dop251/goja@v0.0.0-20230828202809-3dbe69dd2b8e/runtime.go:2285 +0x185
github.com/ydarias/xk6-nats.(*Nats).Subscribe.func1(0xc0025fad90)
        github.com/ydarias/xk6-nats@v0.0.0-20230914104427-9af1a8411f14/nats.go:160 +0x255
github.com/nats-io/nats%2ego.(*Conn).waitForMsgs(0xc001288700, 0xc0027c0f70)
        github.com/nats-io/nats.go@v1.28.0/nats.go:3001 +0x442
created by github.com/nats-io/nats%2ego.(*Conn).subscribeLocked
        github.com/nats-io/nats.go@v1.28.0/nats.go:4232 +0x3f8```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant