grafana/k6 · error
unpacking scroll offset
Error message
unpacking scroll offset: %w
What it means
Raised in screenshotElement after the window.scrollX/scrollY evaluation succeeded but its result could not be converted (via the convert helper) into the expected Position struct {X, Y float64}. This is a shape/type mismatch: the CDP Runtime.evaluate result came back in a form (e.g. not a remote object with numeric properties) that cannot be unmarshalled, indicating an unexpected or corrupted evaluation payload rather than a page-level problem.
Solutions
- This is an internal conversion failure; report it as a k6 browser module bug with the page HTML and reproduction script
- Update k6 to the latest version where conversion of CDP remote objects may have been fixed
- Test with a simpler page to see if a specific page construct triggers the malformed payload
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/screenshotter.go:329 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/c5f29661924745ab.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/screenshotter.go:351
if err != nil {
return nil, fmt.Errorf("node is either not visible or not an HTMLElement: %w", err)
}
if bbox.Width <= 0 {
return nil, fmt.Errorf("node has 0 width")
}
if bbox.Height <= 0 {
return nil, fmt.Errorf("node has 0 height")
}
}
scrollOffset, err := h.Evaluate(`() => { return {x: window.scrollX, y: window.scrollY};}`)
if err != nil {
return nil, fmt.Errorf("evaluating scroll offset: %w", err)
}
var returnVal Position
if err := convert(scrollOffset, &returnVal); err != nil {
return nil, fmt.Errorf("unpacking scroll offset: %w", err)
}
documentRect := bbox
documentRect.X += returnVal.X
documentRect.Y += returnVal.Y
return s.screenshot(
h.frame.page.session,
documentRect.enclosingIntRect(),
nil, // viewportRect
format,
opts.OmitBackground,
opts.Quality,
opts.Path,
)
}
func (s *screenshotter) screenshotPage(p *Page, opts *PageScreenshotOptions) (buf []byte, err error) {View on GitHub (pinned to 3fcf5388d7)