grafana/k6 · error
evaluating handle of
Error message
evaluating handle of %q: unexpected type %T
What it means
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.
Solutions
- Retry the evaluation after the page settles
- Report as a k6 browser module bug with a reproducing script
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/frame.go:2314 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18).
Data as JSON: /api/errors/667dd8dea669038c.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/frame.go:2322
func (f *Frame) evaluateHandleWithSelector(selector string, pageFunc string, args ...any) (JSHandleAPI, error) {
f.log.Debugf("Frame:evaluateHandleWithSelector", "fid:%s furl:%q sel:%q", f.ID(), f.URL(), selector)
evaluateHandle := func(apiCtx context.Context, handle *ElementHandle) (any, error) {
return handle.EvaluateHandle(pageFunc, args...)
}
act := f.newAction(
selector, DOMElementStateAttached, true, evaluateHandle, []string{}, false, withRetry, true, f.defaultTimeout(),
)
v, err := call(f.ctx, act, f.defaultTimeout())
if err != nil {
return nil, errorFromDOMError(err)
}
handle, ok := v.(JSHandleAPI)
if !ok {
return nil, fmt.Errorf("evaluating handle of %q: unexpected type %T", selector, v)
}
return handle, nil
}
// frameExecutionContext represents a JS execution context that belongs to Frame.
type frameExecutionContext interface {
// adoptBackendNodeID adopts specified backend node into this execution
// context from another execution context.
adoptBackendNodeID(backendNodeID cdp.BackendNodeID) (*ElementHandle, error)
// adoptElementHandle adopts the specified element handle into this
// execution context from another execution context.
adoptElementHandle(elementHandle *ElementHandle) (*ElementHandle, error)
// eval evaluates the provided JavaScript within this execution context and
// returns a value or handle.
eval(View on GitHub (pinned to 3fcf5388d7)