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

Runtime error with extraHTTPHeaders #111

Closed
kj187 opened this issue Nov 13, 2021 · 2 comments · Fixed by #116
Closed

Runtime error with extraHTTPHeaders #111

kj187 opened this issue Nov 13, 2021 · 2 comments · Fixed by #116
Assignees
Labels
bug Something isn't working next Might be eligible for the next planning (not guaranteed!)

Comments

@kj187
Copy link

kj187 commented Nov 13, 2021

If I add extra HTTP headers, I got a runtime error invalid memory address or nil pointer dereference

Used version: k6 v0.34.1 ((devel), go1.17.2, darwin/amd64)

Used script:

import { sleep } from 'k6';
import launcher from "k6/x/browser";

export default function () {

    const browser = launcher.launch('chromium', {
        headless: false,
        slowMow: '1500ms'  // slow down by 500ms
    });
    const context = browser.newContext({
        extraHTTPHeaders: {
            "X-Access-Token": "myvalue"
        },
    });
    
    const page = context.newPage();

    page.goto('https://www.google.de', { waitUntil: 'load' });

    sleep(3)
    page.screenshot({ path: `screenshots/homepage.png`,  });

    page.close()
    browser.close()

}

I also tried it with

        extraHTTPHeaders: {
            name: "myvalue"
        },

Whole stack trace:

ERRO[0001] panic: runtime error: invalid memory address or nil pointer dereference
goroutine 72 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:24 +0x65
go.k6.io/k6/js.(*VU).runFn.func1()
	go.k6.io/[email protected]/js/runner.go:749 +0x134
panic({0x1d692a0, 0x2d277f0})
	runtime/panic.go:1038 +0x215
github.com/dop251/goja.AssertFunction.func1.1()
	github.com/dop251/[email protected]/runtime.go:2162 +0x74
panic({0x1d692a0, 0x2d277f0})
	runtime/panic.go:1038 +0x215
github.com/dop251/goja.(*vm).try.func1()
	github.com/dop251/[email protected]/vm.go:512 +0x8eb
panic({0x1d692a0, 0x2d277f0})
	runtime/panic.go:1038 +0x215
github.com/grafana/xk6-browser/common.(*BrowserContextOptions).Parse(0xc00249a0d0, {0x219f5a8, 0xc0023ea750}, {0x21be838, 0xc002462bd0})
	github.com/grafana/[email protected]/common/browser_context_options.go:103 +0xf1d
github.com/grafana/xk6-browser/common.(*Browser).NewContext(0xc000556000, {0x21be838, 0xc002462bd0})
	github.com/grafana/[email protected]/common/browser.go:358 +0x3a5
reflect.Value.call({0x1d1e520, 0xc000fae880, 0x3540f18}, {0x1efcf9c, 0x4}, {0xc00080ef60, 0x1, 0xc002363290})
	reflect/value.go:543 +0x814
reflect.Value.Call({0x1d1e520, 0xc000fae880, 0xc002462bd0}, {0xc00080ef60, 0x1, 0x1})
	reflect/value.go:339 +0xc5
github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1({{0x21be838, 0xc002462810}, {0xc002a90160, 0x1, 0x6}})
	github.com/dop251/[email protected]/runtime.go:1757 +0x259
github.com/dop251/goja.(*vm)._nativeCall(0xc0013da100, 0xc0023e4e60, 0x1)
	github.com/dop251/[email protected]/vm.go:2658 +0x223
github.com/dop251/goja.call.exec(0x10, 0xc0013da100)
	github.com/dop251/[email protected]/vm.go:2630 +0x81b
github.com/dop251/goja.(*vm).run(0xc0013da100)
	github.com/dop251/[email protected]/vm.go:402 +0x8b
github.com/dop251/goja.(*baseJsFuncObject)._call(0xc00230e160, {{0x21bf088, 0x2d77300}, {0xc00239b5e0, 0x1, 0x1}}, {0x0, 0x0}, {0x21bf088, 0x2d77300})
	github.com/dop251/[email protected]/func.go:172 +0x2d8
github.com/dop251/goja.(*funcObject).call(...)
	github.com/dop251/[email protected]/func.go:180
github.com/dop251/goja.(*funcObject).Call(0xc0016db860, {{0x21bf088, 0x2d77300}, {0xc00239b5e0, 0x1, 0x1}})
	github.com/dop251/[email protected]/func.go:140 +0xc9
github.com/dop251/goja.AssertFunction.func1.2()
	github.com/dop251/[email protected]/runtime.go:2167 +0x7d
github.com/dop251/goja.(*vm).try(0x10637c2, 0x1051e46)
	github.com/dop251/[email protected]/vm.go:518 +0x1a4
github.com/dop251/goja.AssertFunction.func1({0x21bf088, 0x2d77300}, {0xc00239b5e0, 0xc0016db938, 0x0})
	github.com/dop251/[email protected]/runtime.go:2166 +0x110
go.k6.io/k6/js.(*VU).runFn(0xc002320320, {0x219f5a8, 0xc0023ea300}, 0x60, 0xc00080e4f8, {0xc00239b5e0, 0x1, 0x1})
	go.k6.io/[email protected]/js/runner.go:754 +0x27c
go.k6.io/k6/js.(*ActiveVU).RunOnce(0xc000fae300)
	go.k6.io/[email protected]/js/runner.go:705 +0x37b
go.k6.io/k6/lib/executor.getIterationRunner.func1({0x219f5a8, 0xc0023ea060}, {0x21832e0, 0xc000fae300})
	go.k6.io/[email protected]/lib/executor/helpers.go:88 +0x64
go.k6.io/k6/lib/executor.PerVUIterations.Run.func3({0x2195300, 0xc002320320})
	go.k6.io/[email protected]/lib/executor/per_vu_iterations.go:239 +0x40a
created by go.k6.io/k6/lib/executor.PerVUIterations.Run
	go.k6.io/[email protected]/lib/executor/per_vu_iterations.go:252 +0xbdb

Goja stack:
native
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
@imiric
Copy link
Contributor

imiric commented Nov 15, 2021

Hi, thanks for reporting this! It's definitely a bug. We'll try to get it fixed ASAP, and possibly do a patch release soon.

@imiric imiric added bug Something isn't working next Might be eligible for the next planning (not guaranteed!) labels Nov 15, 2021
imiric pushed a commit that referenced this issue Nov 15, 2021
@imiric imiric self-assigned this Nov 15, 2021
imiric pushed a commit that referenced this issue Nov 15, 2021
@imiric
Copy link
Contributor

imiric commented Nov 16, 2021

Hi @kj187, this should be fixed now. You can build the binary yourself with xk6 build --with github.com/grafana/xk6-browser@main or wait a few days until we make a patch release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next Might be eligible for the next planning (not guaranteed!)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants