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

Display a friendly error when a browser is re-closed #687

Closed
sniku opened this issue Jan 3, 2023 · 0 comments · Fixed by #803
Closed

Display a friendly error when a browser is re-closed #687

sniku opened this issue Jan 3, 2023 · 0 comments · Fixed by #803
Assignees
Labels
bug Something isn't working ux
Milestone

Comments

@sniku
Copy link
Collaborator

sniku commented Jan 3, 2023

Brief summary

The browser panics and dies when chrome is closed by the user by mistake too early.

ERRO[0003] panic: close of closed channel
goroutine 70 [running]: VUs, 0 complete and 0 interrupted iterations
runtime/debug.Stack()----------------------------] 1 VUs  00m02.6s/10m0s  0/1 iters, 1 per VU
	runtime/debug/stack.go:24 +0x65
go.k6.io/k6/js/common.RunWithPanicCatching.func1()
	go.k6.io/k6@v0.42.1-0.20221223154116-08609b50de8f/js/common/util.go:82 +0x191
panic({0x144cc80, 0x192fc00})
	runtime/panic.go:884 +0x212
github.com/dop251/goja.(*Runtime).runWrapped.func1()
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/runtime.go:2445 +0xdc
panic({0x144cc80, 0x192fc00})
	runtime/panic.go:884 +0x212
github.com/dop251/goja.(*vm).handleThrow(0xc00261e240, {0x144cc80, 0x192fc00})
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/vm.go:725 +0x418
github.com/dop251/goja.(*vm).try.func1()
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/vm.go:744 +0x45
panic({0x144cc80, 0x192fc00})
	runtime/panic.go:884 +0x212
github.com/dop251/goja.(*vm).handleThrow(0xc00261e240, {0x144cc80, 0x192fc00})
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/vm.go:725 +0x418
github.com/dop251/goja.(*vm).runTryInner.func1()
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/vm.go:767 +0x45
panic({0x144cc80, 0x192fc00})
	runtime/panic.go:884 +0x212
github.com/grafana/xk6-browser/common.(*Connection).IgnoreIOErrors(0x0?)
	github.com/grafana/xk6-browser@v0.7.0/common/connection.go:550 +0x25
github.com/grafana/xk6-browser/common.(*Browser).Close(0xc0026690e0)
	github.com/grafana/xk6-browser@v0.7.0/common/browser.go:415 +0xea
reflect.Value.call({0x15b3300?, 0xc0026690e0?, 0x23c9380?}, {0x1634716, 0x4}, {0x2622ee0, 0x0, 0xc00265ee40?})
	reflect/value.go:584 +0x8c5
reflect.Value.Call({0x15b3300?, 0xc0026690e0?, 0x0?}, {0x2622ee0?, 0x0?, 0x0?})
	reflect/value.go:368 +0xbc
github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1({{0x194e0b8, 0xc0010b8150}, {0xc001cebb40, 0x0, 0x4}})
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/runtime.go:1988 +0x1da
github.com/dop251/goja.(*nativeFuncObject).vmCall(0xc000d10a80, 0xc00261e240, 0x0)
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/func.go:509 +0x21b
github.com/dop251/goja.call.exec(0x5?, 0xc00261e240)
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/vm.go:3305 +0x6a
github.com/dop251/goja.(*vm).run(0xc00261e240)
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/vm.go:572 +0x38
github.com/dop251/goja.(*vm).runTryInner(0xc00261e240?)
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/vm.go:771 +0x70
github.com/dop251/goja.(*baseJsFuncObject).__call(0xc0025bd5e0, {0x0?, 0x0, 0x8?}, {0x0?, 0x0}, {0x0?, 0x0?})
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/func.go:376 +0x665
github.com/dop251/goja.(*baseJsFuncObject)._call(...)
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/func.go:392
github.com/dop251/goja.(*arrowFuncObject).Call(0x8?, {{0x0, 0x0}, {0x0, 0x0, 0x0}})
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/func.go:336 +0x57
github.com/dop251/goja.(*Runtime).promiseProto_finally.func1({{0x194e9a0, 0x2622b20}, {0xc00253d750, 0x1, 0x1}})
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/builtin_promise.go:352 +0xd5
github.com/dop251/goja.(*Runtime).callJobCallback(...)
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/runtime.go:2863
github.com/dop251/goja.(*Runtime).newPromiseReactionJob.func1.1()
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/builtin_promise.go:204 +0x105
github.com/dop251/goja.(*vm).try(0xc00261e240, 0xc00265f540)
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/vm.go:748 +0x243
github.com/dop251/goja.(*Runtime).newPromiseReactionJob.func1()
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/builtin_promise.go:203 +0xb8
github.com/dop251/goja.(*Runtime).leave(0xc0005a0800)
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/runtime.go:2736 +0xef
github.com/dop251/goja.(*Runtime).runWrapped(0xc0005a0800, 0x7fcb74b74108?)
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/runtime.go:2454 +0x11d
github.com/dop251/goja.AssertFunction.func1({0x0?, 0x0?}, {0xc00253d740?, 0x0?, 0x0?})
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/runtime.go:2404 +0x92
github.com/dop251/goja.(*Runtime).wrapPromiseReaction.func1({0x0?, 0x0?})
	github.com/dop251/goja@v0.0.0-20221222152515-69dc13e01785/builtin_promise.go:576 +0x9f
github.com/grafana/xk6-browser/k6ext.promise.func1.1()
	github.com/grafana/xk6-browser@v0.7.0/k6ext/promise.go:46 +0x71
go.k6.io/k6/js/eventloop.(*EventLoop).Start(0xc00261a0f0, 0xc00266e540)
	go.k6.io/k6@v0.42.1-0.20221223154116-08609b50de8f/js/eventloop/eventloop.go:171 +0x196
go.k6.io/k6/js.(*VU).runFn.func2()
	go.k6.io/k6@v0.42.1-0.20221223154116-08609b50de8f/js/runner.go:789 +0xeb
go.k6.io/k6/js/common.RunWithPanicCatching({0x1952360?, 0xc0007a9080?}, 0x40f6e6?, 0x1463100?)
	go.k6.io/k6@v0.42.1-0.20221223154116-08609b50de8f/js/common/util.go:86 +0x87
go.k6.io/k6/js.(*VU).runFn(0xc0026543c0, {0x19400c0, 0xc0008131c0}, 0x20?, 0xc0007d8588, 0xc00299edd0, {0xc00299ede0, 0x1, 0x1})
	go.k6.io/k6@v0.42.1-0.20221223154116-08609b50de8f/js/runner.go:788 +0x28a
go.k6.io/k6/js.(*ActiveVU).RunOnce(0xc000813180)
	go.k6.io/k6@v0.42.1-0.20221223154116-08609b50de8f/js/runner.go:733 +0x412
go.k6.io/k6/lib/executor.getIterationRunner.func1({0x1940168, 0xc00266e330}, {0x1934b20?, 0xc000813180?})
	go.k6.io/k6@v0.42.1-0.20221223154116-08609b50de8f/lib/executor/helpers.go:124 +0x64
go.k6.io/k6/lib/executor.PerVUIterations.Run.func5({0x193b418, 0xc0026543c0})
	go.k6.io/k6@v0.42.1-0.20221223154116-08609b50de8f/lib/executor/per_vu_iterations.go:227 +0x40a
created by go.k6.io/k6/lib/executor.PerVUIterations.Run
	go.k6.io/k6@v0.42.1-0.20221223154116-08609b50de8f/lib/executor/per_vu_iterations.go:240 +0xc29

Goja stack:
native 

xk6-browser version

xk6 build gojaAsyncAwait --with github.com/grafana/xk6-browser@main

OS

Linux 6.0.0-5-amd64

Chrome version

Chromium 108.0.5359.124 built on Debian bookworm/sid, running on Debian bookworm/sid

Docker version and image (if applicable)

No response

Steps to reproduce the problem

import { sleep } from 'k6';
import { chromium } from 'k6/x/browser';

export default async function () {
    const browser = chromium.launch({ headless: false });
    const page = browser.newPage();

    await page
        .goto('https://test.k6.io/', { waitUntil: 'networkidle' })
        .finally(() => {
            page.close();
            browser.close();
        });

    await page
        .goto('https://test.k6.io/contacts.php', { waitUntil: 'networkidle' })
        .finally(() => {
            page.close();
            browser.close();
        });

   sleep(30)
}

Expected behaviour

Nice error message about browser being closed

Actual behaviour

💥

@sniku sniku added the bug Something isn't working label Jan 3, 2023
@inancgumus inancgumus changed the title panic: close of closed channel Display a friendly error when a browser is re-closed Jan 4, 2023
@inancgumus inancgumus added the ux label Jan 4, 2023
@inancgumus inancgumus added this to the v0.9.0 milestone Feb 2, 2023
@inancgumus inancgumus self-assigned this Feb 2, 2023
inancgumus added a commit that referenced this issue Mar 2, 2023
Also displays a friendly warning when the test script closes the browser
multiple times.

Closes: #687
inancgumus added a commit that referenced this issue Mar 2, 2023
inancgumus added a commit that referenced this issue Mar 2, 2023
@inancgumus inancgumus linked a pull request Mar 2, 2023 that will close this issue
inancgumus added a commit that referenced this issue Mar 3, 2023
inancgumus added a commit that referenced this issue Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ux
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants