grafana/k6 · error
evaluating handle for page
Error message
evaluating handle for page: %w
What it means
Wrapped failure from Frame.EvaluateHandle while executing the given page function in the main frame's context and wrapping the result in a JSHandle. Fires when the script throws, is not valid JS, the execution context is destroyed by navigation, or the CDP evaluate call fails.
Solutions
- Verify the page function is syntactically valid and runs without exceptions
- Await navigation before evaluating, or retry on context-destroyed errors
- Use Evaluate for plain values; EvaluateHandle only when a handle is needed
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/page.go:1126 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/8f2ea7f06005917e.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/page.go:1131
applySlowMo(p.ctx)
return nil
}
// Evaluate runs JS code within the execution context of the main frame of the page.
func (p *Page) Evaluate(pageFunc string, args ...any) (any, error) {
p.logger.Debugf("Page:Evaluate", "sid:%v", p.sessionID())
return p.MainFrame().Evaluate(pageFunc, args...)
}
// EvaluateHandle runs JS code within the execution context of the main frame of the page.
func (p *Page) EvaluateHandle(pageFunc string, args ...any) (JSHandleAPI, error) {
p.logger.Debugf("Page:EvaluateHandle", "sid:%v", p.sessionID())
h, err := p.MainFrame().EvaluateHandle(pageFunc, args...)
if err != nil {
return nil, fmt.Errorf("evaluating handle for page: %w", err)
}
return h, nil
}
// Fill fills an input element with the provided value.
func (p *Page) Fill(selector string, value string, popts *FrameFillOptions) error {
p.logger.Debugf("Page:Fill", "sid:%v selector:%s", p.sessionID(), selector)
return p.MainFrame().Fill(selector, value, popts)
}
// Focus focuses an element matching the provided selector.
func (p *Page) Focus(selector string, popts *FrameBaseOptions) error {
p.logger.Debugf("Page:Focus", "sid:%v selector:%s", p.sessionID(), selector)
return p.MainFrame().Focus(selector, popts)
}
View on GitHub (pinned to 3fcf5388d7)