Hi, I’m trying to use https://github.com/imiric/xk6-sql to connect to a postgres database. I’m getting the following go error:
ERRO[0001] panic: runtime error: invalid memory address or nil pointer dereference
goroutine 57 [running]:
runtime/debug.Stack(0xc000544808, 0xc000544828, 0xc0005447f8)
runtime/debug/stack.go:24 +0x9f
github.com/loadimpact/k6/js.(*VU).runFn.func1(0xc00036b950, 0xc000545bc0)
github.com/loadimpact/k6@v0.30.1-0.20210223102010-51790fc8df37/js/runner.go:705 +0x1ee
panic(0x1227480, 0x1f84790)
runtime/panic.go:969 +0x1b9
github.com/dop251/goja.AssertFunction.func1.1(0xc000545ac0)
github.com/dop251/goja@v0.0.0-20210216182323-60bc6ebb9fc1/runtime.go:2026 +0x85
panic(0x1227480, 0x1f84790)
runtime/panic.go:969 +0x1b9
github.com/dop251/goja.(*vm).try.func1(0xc00057a000, 0x0, 0xc000545980, 0x0, 0x0, 0x0, 0xc000545a08)
github.com/dop251/goja@v0.0.0-20210216182323-60bc6ebb9fc1/vm.go:406 +0x5d3
panic(0x1227480, 0x1f84790)
runtime/panic.go:969 +0x1b9
database/sql.(*Rows).Columns(0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
database/sql/sql.go:2935 +0x5c
github.com/imiric/xk6-sql.(*SQL).Query(0x21e29b0, 0xc002a0a1a0, 0xc002296000, 0x23, 0x0, 0x0, 0x0)
github.com/imiric/xk6-sql@v0.0.0-20210112090239-90c72e1ef757/sql.go:49 +0x9b
reflect.callMethod(0xc002205c40, 0xc0005451c8, 0xc0005451b0)
reflect/value.go:733 +0x1f6
reflect.methodValueCall(0xc002a0a1a0, 0xc002296000, 0x23, 0x0, 0x0, 0x0, 0xc001009bc8, 0xc000d0dae0, 0xc000545420, 0x4e02c7, ...)
reflect/asm_amd64.s:35 +0x42
reflect.Value.call(0x11f1520, 0xc002205c40, 0x13, 0x13b4922, 0x4, 0xc001009b60, 0x2, 0x2, 0xc0004dd4a0, 0x41c9f8, ...)
reflect/value.go:476 +0x8c7
reflect.Value.Call(0x11f1520, 0xc002205c40, 0x13, 0xc001009b60, 0x2, 0x2, 0xc001184738, 0x0, 0x0)
reflect/value.go:337 +0xb9
github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1(0x16154e0, 0xc000fe60f0, 0xc00057a3f0, 0x2, 0x7, 0xc0003ff9e0, 0x1)
github.com/dop251/goja@v0.0.0-20210216182323-60bc6ebb9fc1/runtime.go:1668 +0x3c9
github.com/dop251/goja.(*vm)._nativeCall(0xc00057a000, 0xc000e88b40, 0x2)
github.com/dop251/goja@v0.0.0-20210216182323-60bc6ebb9fc1/vm.go:1817 +0x2c2
github.com/dop251/goja.call.exec(0x2, 0xc00057a000)
github.com/dop251/goja@v0.0.0-20210216182323-60bc6ebb9fc1/vm.go:1789 +0xaeb
github.com/dop251/goja.(*vm).run(0xc00057a000)
github.com/dop251/goja@v0.0.0-20210216182323-60bc6ebb9fc1/vm.go:307 +0x99
github.com/dop251/goja.(*funcObject).call(0xc0029f5790, 0x1615da0, 0x21e2460, 0xc000d0da80, 0x1, 0x1, 0x0, 0x0, 0xc000644890, 0x41a0c5)
github.com/dop251/goja@v0.0.0-20210216182323-60bc6ebb9fc1/func.go:161 +0x33a
github.com/dop251/goja.(*funcObject).Call(...)
github.com/dop251/goja@v0.0.0-20210216182323-60bc6ebb9fc1/func.go:129
github.com/dop251/goja.AssertFunction.func1.2()
github.com/dop251/goja@v0.0.0-20210216182323-60bc6ebb9fc1/runtime.go:2031 +0x96
github.com/dop251/goja.(*vm).try(0xc00057a000, 0xc000644a28, 0x0)
github.com/dop251/goja@v0.0.0-20210216182323-60bc6ebb9fc1/vm.go:412 +0x163
github.com/dop251/goja.AssertFunction.func1(0x1615da0, 0x21e2460, 0xc000d0da80, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
github.com/dop251/goja@v0.0.0-20210216182323-60bc6ebb9fc1/runtime.go:2030 +0x10b
github.com/loadimpact/k6/js.(*VU).runFn(0xc00036b950, 0x1604340, 0xc001009a40, 0x1, 0xc001564e40, 0xc000d0da80, 0x1, 0x1, 0x0, 0x0, ...)
github.com/loadimpact/k6@v0.30.1-0.20210223102010-51790fc8df37/js/runner.go:710 +0x1b3
github.com/loadimpact/k6/js.(*ActiveVU).RunOnce(0xc0015ae800, 0x0, 0x0)
github.com/loadimpact/k6@v0.30.1-0.20210223102010-51790fc8df37/js/runner.go:658 +0x226
github.com/loadimpact/k6/lib/executor.getIterationRunner.func1(0x1604300, 0xc00258e1e0, 0x15ea700, 0xc0015ae800, 0xc000d0d9d0)
github.com/loadimpact/k6@v0.30.1-0.20210223102010-51790fc8df37/lib/executor/helpers.go:86 +0x5e
github.com/loadimpact/k6/lib/executor.PerVUIterations.Run.func3(0x15f6240, 0xc00036b950)
github.com/loadimpact/k6@v0.30.1-0.20210223102010-51790fc8df37/lib/executor/per_vu_iterations.go:231 +0x237
created by github.com/loadimpact/k6/lib/executor.PerVUIterations.Run
github.com/loadimpact/k6@v0.30.1-0.20210223102010-51790fc8df37/lib/executor/per_vu_iterations.go:244 +0xc9c
Goja stack:
file:///home/simon/Documents/git/test-sql-k6/script.js:23:302(69)
ERRO[0001] a panic occurred in VU code but was caught: runtime error: invalid memory address or nil pointer dereference executor=per-vu-iterations scenario=default
I built k6 using the following commands
git clone https://github.com/k6io/xk6.git
cd xk6
CGO_ENABLED=1 go run ./cmd/xk6/main.go build master \
--with github.com/imiric/xk6-sql
And here’s the script I’m running:
import sql from 'k6/x/sql';
const connStr = "postgres://postgres:abcd111@postgresql.url.net/employees?sslmode=verify-full"
const db = sql.open('postgres', connStr);
export function setup() {
// Create data here.
}
export function teardown() {
db.close();
}
export default function () {
// db.exec(
// "INSERT INTO keyvalues (key, value) VALUES('plugin-name', 'k6-plugin-sql');"
// );
let results = sql.query(db, 'SELECT * FROM departments LIMIT 10;');
for (const row of results) {
console.log(`key: ${row.key}, value: ${row.value}`);
}
}
Can anyone help? It’s not possible to raise issues on the repo.
Thanks