You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
k6-browser is throwing various non-repeating errors using the non-experimental k6/browser usually seen within calls to page.evaluate
k6 version
0.55.0
OS
macOS 15.1.1
Docker version and image (if applicable)
docker.desktop 4.35.1 (173168)
Steps to reproduce the problem
Here is an excerpt of our sendSocketChatMsg function that works as expected with the k6/experimental/browser but inevitably panics in different ways within the evaluated callback when using the stable k6/browser. I will post some of the panics I am seeing in the Actual Behavior section
exportconstgenerateUUID=()=>{// UUIDv4 pattern: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxxreturn"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){constr=(Math.random()*16)|0,v=c=="x" ? r : (r&0x3)|0x8;returnv.toString(16);});};constisSpecialChatDestination=(msgTo: string)=>{returnObject.values(DISPLAY_NAMES).includes(msgToasDISPLAY_NAMES);};exportconstsendSocketChatMsg=async(page: Page,robotName: string,msg?: string,msgTo?: string)=>{try{constid=generateUUID();letspecialDestination;if(!msgTo){// eslint-disable-next-line no-param-reassignmsgTo=DISPLAY_NAMES.ROOMasstring;specialDestination=true;}elseif(msgTo==="Staff"){// eslint-disable-next-line no-param-reassignmsgTo=DISPLAY_NAMES.STAFF_IN_ROOMasstring;specialDestination=true;}elseif(msgTo==="Room"){// eslint-disable-next-line no-param-reassignmsgTo=DISPLAY_NAMES.ROOMasstring;specialDestination=true;}else{// check for special destination:specialDestination=isSpecialChatDestination(msgTo);}console.log(`${newDate().toISOString()}${robotName} %%%% call page.evaluate for chat`,{
robotName,
msg,
msgTo,
id,
specialDestination,});awaitpage.evaluate((data)=>{
let userName: string;try{conststudentSocketConnectionInstance=window.globalSocketConnection.getInstance();if(!studentSocketConnectionInstance){return{rc: -1,err: "No socket found"};}conststudentState=window.globalStudentState;letname;if(data.specialDestination){// room, staff etc, no lookup neededuserName=data.msgTo;name=data.msgTo;}else{consttargetUser=studentState.participants.find((x: any)=>x.name.startsWith(data.msgTo));userName=targetUser?.userName;name=targetUser?.name;}constmessage=data.msg&&userName
? data.msg
: !userName
? `FAILED TO FIND RECIPIENT: ${data.msgTo} for msg (${data.msg})`
: "No message text found";studentSocketConnectionInstance.sendChatMessage({id: data.id,text: message,when: newDate().toISOString(),// emailtargetUser: userName||"STAFF_IN_ROOM",roomId: studentState.roomId,vtgId: studentState.vtgId,// display nametargetName: name||"STAFF_IN_ROOM",authorUserName: studentState.username,authorDisplayName: studentState.displayName,targetRoomId: studentState.roomId,shouldNotify: false,}).then((res: any)=>console.log("Send Chat res:",res)).catch((err: Error)=>console.log("ERROR sendChatMsg robot",{robotName: data.robotName, userName },err,err.toString(),),).finally(()=>null);console.log(data.robotName,"CHAT from socket done");return0;}catch(err){console.log("ERROR: robot chat msg send",data,err);return{rc: -1, err };}},{ robotName, msg, msgTo, id, specialDestination },);console.log(`${newDate().toISOString()}${robotName} %%%% call page.evaluate for chat: DONE`);return0;}catch(err){console.error(`${newDate().toISOString()}${robotName} ERROR sendSocketChatMsg`,err,(errasError).toString(),{ msg, msgTo },);return{rc: -1, err };}};
Expected behaviour
This works as expected with the old k6/experimental/browser the call to studentSocketConnectionInstance.sendChatMessage is successful.
Actual behaviour
panic: TypeError: Object has no member 'call' at call (native)
running (01m01.7s), 3/3 VUs, 0 complete and 0 interrupted iterations
goroutine 4204 [running]:--------------------------------] 3 VUs 01m01.7s/26m40s 0/3 iters, 1 per VU
github.com/grafana/sobek.(baseJsFuncObject)._call(...)
github.com/grafana/[email protected]/func.go:444
github.com/grafana/sobek.(baseJsFuncObject).call(0x0?, {{0x106612518, 0x14001557980}, {0x0, 0x0, 0x0}}, {0x0?, 0x0?})
github.com/grafana/[email protected]/func.go:450 +0x94
github.com/grafana/sobek.(baseJsFuncObject).Call(...)
github.com/grafana/[email protected]/func.go:382
github.com/grafana/sobek.(Object).tryPrimitive(0x14001557980, {0x105dcbfc9?, 0x0?})
github.com/grafana/[email protected]/object.go:842 +0xac
github.com/grafana/sobek.(Object).ordinaryToPrimitiveString(0x14001557980)
github.com/grafana/[email protected]/object.go:866 +0x2c
github.com/grafana/sobek.(Object).toPrimitiveString(0x14001557980)
github.com/grafana/[email protected]/object.go:905 +0x48
github.com/grafana/sobek.(*Object).String(0x0?)
github.com/grafana/[email protected]/value.go:715 +0x1c
github.com/grafana/xk6-browser/browser.mapPage.func11.1()
github.com/grafana/[email protected]/browser/page_mapping.go:85 +0x44
github.com/grafana/xk6-browser/k6ext.promise.func1()
github.com/grafana/[email protected]/k6ext/promise.go:24 +0x38
created by github.com/grafana/xk6-browser/k6ext.promise in goroutine 102
github.com/grafana/[email protected]/k6ext/promise.go:23 +0x98
panic: runtime error: slice bounds out of range [20:0] [recovered]
running panic: runtime error: slice bounds out of range [20:0]ations
perVuIterations [--------------------------------------] 1 VUs 01m21.9s/26m40s 0/1 iters, 1 per VU
goroutine 104 [running]:
github.com/grafana/sobek.(Runtime).runWrapped.func1()
github.com/grafana/[email protected]/runtime.go:2504 +0xf4
panic({0x102282300?, 0x140001d0db0?})
runtime/panic.go:785 +0x124
github.com/grafana/sobek.(vm).clearStack(0x14000b52a20)
github.com/grafana/[email protected]/vm.go:3727 +0xb4
github.com/grafana/sobek.(Runtime).runWrapped(0x140011c6c08, 0x14000101008?)
github.com/grafana/[email protected]/runtime.go:2515 +0x90
github.com/grafana/sobek.AssertFunction.func1({0x0?, 0x0?}, {0x140015bd030?, 0x0?, 0x0?})
github.com/grafana/[email protected]/runtime.go:2463 +0x78
github.com/grafana/sobek.(Runtime).wrapPromiseReaction.func1({0x1020f0c80?, 0x14000623ce0?})
github.com/grafana/[email protected]/builtin_promise.go:602 +0xa8
go.k6.io/k6/js/promises.New.func2.1()
go.k6.io/[email protected]/js/promises/promises.go:43 +0x2c
go.k6.io/k6/js/eventloop.(EventLoop).Start(0x140008a5c20, 0x14000c90300)
go.k6.io/[email protected]/js/eventloop/eventloop.go:177 +0x160
go.k6.io/k6/js.(VU).runFn(0x14001397900, {0x1023aeb68, 0x14000dd14f0}, 0x1, 0x140015543d8, 0x140014e9d90, {0x1400123a280, 0x1, 0x1})
go.k6.io/[email protected]/js/runner.go:840 +0x1f4
go.k6.io/k6/js.(*ActiveVU).RunOnce(0x14000f4dbc0)
go.k6.io/[email protected]/js/runner.go:773 +0x3d0
go.k6.io/k6/lib/executor.PerVUIterations.Run.getIterationRunner.func7({0x1023aeb30, 0x1400155a360}, {0x102397fa0?, 0x14000f4dbc0?})
go.k6.io/[email protected]/lib/executor/helpers.go:108 +0x44
go.k6.io/k6/lib/executor.PerVUIterations.Run.func5({0x1023a5ee8, 0x14001397900})
go.k6.io/[email protected]/lib/executor/per_vu_iterations.go:228 +0x318
created by go.k6.io/k6/lib/executor.PerVUIterations.Run in goroutine 102
go.k6.io/[email protected]/lib/executor/per_vu_iterations.go:241 +0x89c
panic: TypeError: Method WeakMap.prototype.get called on incompatible receiver [object Object] at get (native)
running (00m40.2s), 3/3 VUs, 0 complete and 0 interrupted iterations
goroutine 3528 [running]:--------------------------------] 3 VUs 00m40.2s/26m40s 0/3 iters, 1 per VU
github.com/grafana/sobek.(baseJsFuncObject)._call(...)
github.com/grafana/[email protected]/func.go:444
github.com/grafana/sobek.(baseJsFuncObject).call(0x0?, {{0x10264e688, 0x14001a91c20}, {0x0, 0x0, 0x0}}, {0x0?, 0x0?})
github.com/grafana/[email protected]/func.go:450 +0x94
github.com/grafana/sobek.(baseJsFuncObject).Call(...)
github.com/grafana/[email protected]/func.go:382
github.com/grafana/sobek.(Object).tryPrimitive(0x14001a91c20, {0x101e07b99?, 0x527261656c632e66?})
github.com/grafana/[email protected]/object.go:842 +0xac
github.com/grafana/sobek.(Object).ordinaryToPrimitiveString(0x14001a91c20)
github.com/grafana/[email protected]/object.go:866 +0x2c
github.com/grafana/sobek.(Object).toPrimitiveString(0x14001a91c20)
github.com/grafana/[email protected]/object.go:905 +0x48
github.com/grafana/sobek.(*Object).String(0x766e61632c7d752c?)
github.com/grafana/[email protected]/value.go:715 +0x1c
github.com/grafana/xk6-browser/browser.mapPage.func11.1()
github.com/grafana/[email protected]/browser/page_mapping.go:85 +0x44
github.com/grafana/xk6-browser/k6ext.promise.func1()
github.com/grafana/[email protected]/k6ext/promise.go:24 +0x38
created by github.com/grafana/xk6-browser/k6ext.promise in goroutine 115
github.com/grafana/[email protected]/k6ext/promise.go:23 +0x98
Any chance you could send us a full test script that exhibits this issue when working with k6/browser vs k6/experimental/browser? I can't see anything obvious that could cause any issues or replicate the issue with the excerpt you have given us. Also, what version of k6 are you running?
Brief summary
k6-browser is throwing various non-repeating errors using the non-experimental k6/browser usually seen within calls to page.evaluate
k6 version
0.55.0
OS
macOS 15.1.1
Docker version and image (if applicable)
docker.desktop 4.35.1 (173168)
Steps to reproduce the problem
Here is an excerpt of our sendSocketChatMsg function that works as expected with the k6/experimental/browser but inevitably panics in different ways within the evaluated callback when using the stable k6/browser. I will post some of the panics I am seeing in the Actual Behavior section
Expected behaviour
This works as expected with the old k6/experimental/browser the call to studentSocketConnectionInstance.sendChatMessage is successful.
Actual behaviour
The text was updated successfully, but these errors were encountered: