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

Dispose: Cannot find context with specified id (-32000) #1144

Closed
2 tasks done
Tracked by #1138
VincentDugard opened this issue Dec 19, 2023 · 4 comments
Closed
2 tasks done
Tracked by #1138

Dispose: Cannot find context with specified id (-32000) #1144

VincentDugard opened this issue Dec 19, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@VincentDugard
Copy link

VincentDugard commented Dec 19, 2023

Brief summary

Hello, I'm trying to use xk6 with a nextjs webapp.
Everything work fine until I click a button that unmount components.
The following error appear

panic: GoError: dispose: disposing element with ID 6465351156197874064.11.1: Cannot find context with specified id (-32000)
running (00m10.4s), 1/1 VUs, 0 complete and 0 interrupted iterations
goroutine 119 [running]:----------------------] 1 VUs  00m10.4s/10m0s  0/1 shared iters
go.k6.io/k6/js/common.Throw(0x1902650?, {0x1c1bb20?, 0xc001cb6080?})
        go.k6.io/[email protected]/js/common/util.go:20 +0x4d
github.com/grafana/xk6-browser/k6ext.Panic.func1(0x1698700?, {0xc0016d4da0?, 0x1734501?, 0xc0014ae100?})
        github.com/grafana/[email protected]/k6ext/panic.go:35 +0x4a
github.com/grafana/xk6-browser/k6ext.sharedPanic({0x1c2ea10, 0xc0006358b0}, 0xc00054fa38, {0xc0016d4da0?, 0x1, 0x1})
        github.com/grafana/[email protected]/k6ext/panic.go:64 +0x265
github.com/grafana/xk6-browser/k6ext.Panic({0x1c2ea10?, 0xc0006358b0?}, {0x1902650?, 0xc0016d4a10?}, {0xc0016d4da0?, 0xc0016d4a30?, 0x162af00?})
        github.com/grafana/[email protected]/k6ext/panic.go:37 +0x65
github.com/grafana/xk6-browser/common.(*BaseJSHandle).Dispose(0xc003887540)
        github.com/grafana/[email protected]/common/js_handle.go:84 +0xa9
github.com/grafana/xk6-browser/common.(*Frame).detach(0xc0006661c0)
        github.com/grafana/[email protected]/common/frame.go:243 +0x15e
github.com/grafana/xk6-browser/common.(*FrameManager).removeFramesRecursively(0xc0005f3680, 0xc0020cd0c0?)
        github.com/grafana/[email protected]/common/frame_manager.go:414 +0x265
github.com/grafana/xk6-browser/common.(*FrameManager).frameDetached(0xc0005f3680, {0xc0020cd0c0, 0x20}, {0x18eddf3, 0x6})
        github.com/grafana/[email protected]/common/frame_manager.go:185 +0x166
github.com/grafana/xk6-browser/common.(*FrameSession).onFrameDetached(0xc0014b0580, {0xc0020cd0c0, 0x20}, {0x18eddf3, 0x6})
        github.com/grafana/[email protected]/common/frame_session.go:715 +0x185
github.com/grafana/xk6-browser/common.(*FrameSession).initEvents.func1()
        github.com/grafana/[email protected]/common/frame_session.go:242 +0x5a7
created by github.com/grafana/xk6-browser/common.(*FrameSession).initEvents
        github.com/grafana/[email protected]/common/frame_session.go:216 +0x1ab

xk6-browser version

1.2.1

OS

ubuntu 22.04

Chrome version

119.0.6045.199

Docker version and image (if applicable)

No response

Steps to reproduce the problem

use xk6-browser on react app and manipulate element that you later unmount

Expected behaviour

Not crashing

Actual behaviour

panic: GoError: dispose: disposing element with ID -7740169745649148315.11.1: Cannot find context with specified id (-32000)
running (00m13.8s), 1/1 VUs, 0 complete and 0 interrupted iterations
goroutine 70 [running]:-----------------------] 1 VUs  00m13.8s/10m0s  0/1 shared iters
go.k6.io/k6/js/common.Throw(0x1902650?, {0x1c1bb20?, 0xc001d3fe80?})
        go.k6.io/[email protected]/js/common/util.go:20 +0x4d
github.com/grafana/xk6-browser/k6ext.Panic.func1(0x1698700?, {0xc000dfb6b0?, 0x1734501?, 0xc00165c680?})
        github.com/grafana/[email protected]/k6ext/panic.go:35 +0x4a
github.com/grafana/xk6-browser/k6ext.sharedPanic({0x1c2ea10, 0xc000a36e60}, 0xc0009c5a38, {0xc000dfb6b0?, 0x1, 0x1})
        github.com/grafana/[email protected]/k6ext/panic.go:64 +0x265
github.com/grafana/xk6-browser/k6ext.Panic({0x1c2ea10?, 0xc000a36e60?}, {0x1902650?, 0xc0008239b0?}, {0xc000dfb6b0?, 0xc0008239e0?, 0x162af00?})
        github.com/grafana/[email protected]/k6ext/panic.go:37 +0x65
github.com/grafana/xk6-browser/common.(*BaseJSHandle).Dispose(0xc0012f7310)
        github.com/grafana/[email protected]/common/js_handle.go:84 +0xa9
github.com/grafana/xk6-browser/common.(*Frame).detach(0xc004a1a000)
        github.com/grafana/[email protected]/common/frame.go:243 +0x15e
github.com/grafana/xk6-browser/common.(*FrameManager).removeFramesRecursively(0xc0022c7800, 0xc001681220?)
        github.com/grafana/[email protected]/common/frame_manager.go:414 +0x265
github.com/grafana/xk6-browser/common.(*FrameManager).frameDetached(0xc0022c7800, {0xc001681220, 0x20}, {0x18eddf3, 0x6})
        github.com/grafana/[email protected]/common/frame_manager.go:185 +0x166
github.com/grafana/xk6-browser/common.(*FrameSession).onFrameDetached(0xc00044ca50, {0xc001681220, 0x20}, {0x18eddf3, 0x6})
        github.com/grafana/[email protected]/common/frame_session.go:715 +0x185
github.com/grafana/xk6-browser/common.(*FrameSession).initEvents.func1()
        github.com/grafana/[email protected]/common/frame_session.go:242 +0x5a7
created by github.com/grafana/xk6-browser/common.(*FrameSession).initEvents
        github.com/grafana/[email protected]/common/frame_session.go:216 +0x1ab

Tasks

@VincentDugard VincentDugard added the bug Something isn't working label Dec 19, 2023
@inancgumus
Copy link
Member

Hi @VincentDugard, we can't reproduce this issue without a script and a website to test against. Please provide these details in the issue description.

@inancgumus
Copy link
Member

A similar error has occurred here (while testing TestShadowDOMAndDocumentFragment):

time="2024-04-26T13:03:45Z" level=error msg="process with PID 8313 unexpectedly ended: exit status 1" category=browser elapsed="0 ms" source=browser
time="2024-04-26T13:03:45Z" level=error msg="process with PID 83[57](https://github.com/grafana/xk6-browser/actions/runs/8848707815/job/24299055479?pr=1288#step:4:58) unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-04-26T13:03:46Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-04-26T13:03:46Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-04-26T13:03:46Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-04-26T13:03:46Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-04-26T13:03:46Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-04-26T13:03:46Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-04-26T13:03:47Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-04-26T13:03:47Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-04-26T13:03:47Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-04-26T13:03:47Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-04-26T13:03:48Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-04-26T13:03:48Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-04-26T13:03:53Z" level=error msg="error on evaluating window.k6SpanId: evaluating JS in global context: context canceled" category="FrameSession:onFrameNavigated" elapsed="0 ms" source=browser
time="2024-04-26T13:03:53Z" level=error msg="error on evaluating window.k6SpanId: evaluating JS in global context: context canceled" category="FrameSession:onFrameNavigated" elapsed="0 ms" source=browser
time="2024-04-26T13:03:53Z" level=error msg="error on evaluating window.k6SpanId: evaluating JS in global context: context canceled" category="FrameSession:onFrameNavigated" elapsed="0 ms" source=browser
--- FAIL: TestShadowDOMAndDocumentFragment (16.32s)
    --- FAIL: TestShadowDOMAndDocumentFragment/waitFor_ShadowRoot_DocumentFragment (3.23s)
        page_test.go:1697: 
            	Error Trace:	/home/runner/work/xk6-browser/xk6-browser/tests/page_test.go:1697
            	Error:      	Received unexpected error:
            	            	GoError: waiting for "//p[@id=\"inShadowRootDocFrag\"]": getting new document handle: getting document element handle: Cannot find context with specified id at github.com/grafana/xk6-browser/common.(*Locator).WaitFor-fm (native)
            	Test:       	TestShadowDOMAndDocumentFragment/waitFor_ShadowRoot_DocumentFragment
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=0x40 pc=0x1ad799e]

goroutine 1689 [running]:
testing.tRunner.func1.2({0x1c0aae0, 0x2da7270})
	/opt/hostedtoolcache/go/1.21.9/x64/src/testing/testing.go:1545 +0x3f7
testing.tRunner.func1()
	/opt/hostedtoolcache/go/1.21.9/x64/src/testing/testing.go:1548 +0x716
panic({0x1c0aae0?, 0x2da7270?})
	/opt/hostedtoolcache/go/1.21.9/x64/src/runtime/panic.go:920 +0x270
github.com/grafana/xk6-browser/tests.TestShadowDOMAndDocumentFragment.func1(0x0?)
	/home/runner/work/xk6-browser/xk6-browser/tests/page_test.go:1698 +0x1fe
testing.tRunner(0xc000e009c0, 0xc0001b17c0)
	/opt/hostedtoolcache/go/1.21.9/x64/src/testing/testing.go:1[59](https://github.com/grafana/xk6-browser/actions/runs/8848707815/job/24299055479?pr=1288#step:4:60)5 +0x262
created by testing.(*T).Run in goroutine 669
	/opt/hostedtoolcache/go/1.21.9/x64/src/testing/testing.go:1648 +0x846
FAIL	github.com/grafana/xk6-browser/tests	19.217s
FAIL

@inancgumus
Copy link
Member

inancgumus commented May 8, 2024

@ankur22 Should we reopen this or add another issue? It seems to be happening again (maybe not related to this one, I'm not sure). It might be because of using promises—I haven't looked into it yet. WDYT?

--- FAIL: TestBrowserCrashErr (0.11s)
    browser_test.go:241: 
        	Error Trace:	/home/runner/work/xk6-browser/xk6-browser/tests/browser_test.go:241
        	Error:      	Error "error building browser on IterStart: launching browser: browser process ended unexpectedly at <eval>:1:1(0)" does not contain "launching browser: Invalid devtools server port"
        	Test:       	TestBrowserCrashErr
time="2024-05-08T10:20:33Z" level=error msg="process with PID 5654 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-05-08T10:20:33Z" level=error msg="Failed to load resource: the server responded with a status of 404 (Not Found)" browser_source=network line_number=0 source=browser stacktrace="<nil>" url="http://127.0.0.1:35567/ping"
time="2024-05-08T10:20:33Z" level=error msg="error on evaluating window.k6SpanId: evaluating JS in global context: context canceled" category="FrameSession:onFrameNavigated" elapsed="0 ms" source=browser
time="2024-05-08T10:20:36Z" level=error msg="communicating with browser: websocket: close 1006 (abnormal closure): unexpected EOF" category=cdp elapsed="0 ms" source=browser
time="2024-05-08T10:20:36Z" level=error msg="process with PID 6918 unexpectedly ended: signal: killed" category=browser elapsed="11 ms" source=browser
time="2024-05-08T10:20:38Z" level=error msg="error on evaluating window.k6SpanId: evaluating JS in global context: context canceled" category="FrameSession:onFrameNavigated" elapsed="0 ms" source=browser
time="2024-05-08T10:20:38Z" level=error msg="Failed to load resource: the server responded with a status of 404 (Not Found)" browser_source=network line_number=0 source=browser stacktrace="<nil>" url="http://127.0.0.1:38151/static/empty.html"
time="2024-05-08T10:20:38Z" level=error msg="error on evaluating window.k6SpanId: evaluating JS in global context: context canceled" category="FrameSession:onFrameNavigated" elapsed="0 ms" source=browser
time="2024-05-08T10:20:39Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-05-08T10:20:46Z" level=error msg="communicating with browser: websocket: close 1006 (abnormal closure): unexpected EOF" category=cdp elapsed="0 ms" source=browser
time="2024-05-08T10:20:46Z" level=error msg="process with PID 10028 unexpectedly ended: signal: killed" category=browser elapsed="2 ms" source=browser
time="2024-05-08T10:20:48Z" level=error msg="error on evaluating window.k6SpanId: evaluating JS in global context: context canceled" category="FrameSession:onFrameNavigated" elapsed="0 ms" source=browser
--- FAIL: TestK6Object (0.00s)
    --- FAIL: TestK6Object/with_testRunId (0.68s)
        browser_context_test.go:667: 
            	Error Trace:	/home/runner/work/xk6-browser/xk6-browser/tests/browser_context_test.go:667
            	Error:      	Received unexpected error:
            	            	Uncaught (in promise) GoError: evaluating JS: Cannot find context with specified id
            	            		at github.com/grafana/xk6-browser/browser.mapPage.func4 (native)
            	            		at <eval>:5:26(14)
            	Test:       	TestK6Object/with_testRunId

Commit: a3b0093

Failure: https://github.com/grafana/xk6-browser/actions/runs/9000161266/job/24723817613?pr=1312

@ankur22
Copy link
Collaborator

ankur22 commented May 8, 2024

@ankur22 Should we reopen this or add another issue? It seems to be happening again (maybe not related to this one, I'm not sure). It might be because of using promises—I haven't looked into it yet. WDYT?

--- FAIL: TestBrowserCrashErr (0.11s)
    browser_test.go:241: 
        	Error Trace:	/home/runner/work/xk6-browser/xk6-browser/tests/browser_test.go:241
        	Error:      	Error "error building browser on IterStart: launching browser: browser process ended unexpectedly at <eval>:1:1(0)" does not contain "launching browser: Invalid devtools server port"
        	Test:       	TestBrowserCrashErr
time="2024-05-08T10:20:33Z" level=error msg="process with PID 5654 unexpectedly ended: signal: killed" category=browser elapsed="0 ms" source=browser
time="2024-05-08T10:20:33Z" level=error msg="Failed to load resource: the server responded with a status of 404 (Not Found)" browser_source=network line_number=0 source=browser stacktrace="<nil>" url="http://127.0.0.1:35567/ping"
time="2024-05-08T10:20:33Z" level=error msg="error on evaluating window.k6SpanId: evaluating JS in global context: context canceled" category="FrameSession:onFrameNavigated" elapsed="0 ms" source=browser
time="2024-05-08T10:20:36Z" level=error msg="communicating with browser: websocket: close 1006 (abnormal closure): unexpected EOF" category=cdp elapsed="0 ms" source=browser
time="2024-05-08T10:20:36Z" level=error msg="process with PID 6918 unexpectedly ended: signal: killed" category=browser elapsed="11 ms" source=browser
time="2024-05-08T10:20:38Z" level=error msg="error on evaluating window.k6SpanId: evaluating JS in global context: context canceled" category="FrameSession:onFrameNavigated" elapsed="0 ms" source=browser
time="2024-05-08T10:20:38Z" level=error msg="Failed to load resource: the server responded with a status of 404 (Not Found)" browser_source=network line_number=0 source=browser stacktrace="<nil>" url="http://127.0.0.1:38151/static/empty.html"
time="2024-05-08T10:20:38Z" level=error msg="error on evaluating window.k6SpanId: evaluating JS in global context: context canceled" category="FrameSession:onFrameNavigated" elapsed="0 ms" source=browser
time="2024-05-08T10:20:39Z" level=warning msg="Please call browser.close only once, and do not use the browser after calling close." category="Browser:Close" elapsed="0 ms" source=browser
time="2024-05-08T10:20:46Z" level=error msg="communicating with browser: websocket: close 1006 (abnormal closure): unexpected EOF" category=cdp elapsed="0 ms" source=browser
time="2024-05-08T10:20:46Z" level=error msg="process with PID 10028 unexpectedly ended: signal: killed" category=browser elapsed="2 ms" source=browser
time="2024-05-08T10:20:48Z" level=error msg="error on evaluating window.k6SpanId: evaluating JS in global context: context canceled" category="FrameSession:onFrameNavigated" elapsed="0 ms" source=browser
--- FAIL: TestK6Object (0.00s)
    --- FAIL: TestK6Object/with_testRunId (0.68s)
        browser_context_test.go:667: 
            	Error Trace:	/home/runner/work/xk6-browser/xk6-browser/tests/browser_context_test.go:667
            	Error:      	Received unexpected error:
            	            	Uncaught (in promise) GoError: evaluating JS: Cannot find context with specified id
            	            		at github.com/grafana/xk6-browser/browser.mapPage.func4 (native)
            	            		at <eval>:5:26(14)
            	Test:       	TestK6Object/with_testRunId

Commit: a3b0093

Failure: https://github.com/grafana/xk6-browser/actions/runs/9000161266/job/24723817613?pr=1312

I think we should open a new issue for this particular test failure. It could be related to the dispose but it's not possible to tell from the error, especially since the error from the test failure is missing dispose: disposing element with ID 6465351156197874064.11.1 which is what this particular issue resolved.

@inancgumus inancgumus changed the title Cannot find context with specified id (-32000) Dispose: Cannot find context with specified id (-32000) May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants