{"record":{"id":"667dd8dea669038c","repo":"grafana/k6","slug":"evaluating-handle-of-q-unexpected-type-t","errorCode":null,"errorMessage":"evaluating handle of %q: unexpected type %T","messagePattern":"evaluating handle of %q: unexpected type %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":2322,"sourceCode":"\nfunc (f *Frame) evaluateHandleWithSelector(selector string, pageFunc string, args ...any) (JSHandleAPI, error) {\n\tf.log.Debugf(\"Frame:evaluateHandleWithSelector\", \"fid:%s furl:%q sel:%q\", f.ID(), f.URL(), selector)\n\n\tevaluateHandle := func(apiCtx context.Context, handle *ElementHandle) (any, error) {\n\t\treturn handle.EvaluateHandle(pageFunc, args...)\n\t}\n\n\tact := f.newAction(\n\t\tselector, DOMElementStateAttached, true, evaluateHandle, []string{}, false, withRetry, true, f.defaultTimeout(),\n\t)\n\tv, err := call(f.ctx, act, f.defaultTimeout())\n\tif err != nil {\n\t\treturn nil, errorFromDOMError(err)\n\t}\n\n\thandle, ok := v.(JSHandleAPI)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"evaluating handle of %q: unexpected type %T\", selector, v)\n\t}\n\n\treturn handle, nil\n}\n\n// frameExecutionContext represents a JS execution context that belongs to Frame.\ntype frameExecutionContext interface {\n\t// adoptBackendNodeID adopts specified backend node into this execution\n\t// context from another execution context.\n\tadoptBackendNodeID(backendNodeID cdp.BackendNodeID) (*ElementHandle, error)\n\n\t// adoptElementHandle adopts the specified element handle into this\n\t// execution context from another execution context.\n\tadoptElementHandle(elementHandle *ElementHandle) (*ElementHandle, error)\n\n\t// eval evaluates the provided JavaScript within this execution context and\n\t// returns a value or handle.\n\teval(","sourceCodeStart":2304,"sourceCodeEnd":2340,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L2304-L2340","documentation":"Returned by Frame.evaluateHandleWithSelector as a type guard: the EvaluateHandle-on-element action returned a value that is not a JSHandleAPI implementation. Reported with selector and actual Go type; internal contract violation, not user-actionable.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame.go:2314 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the evaluation after the page settles","Report as a k6 browser module bug with a reproducing script"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}