{"record":{"id":"4d2bb1cd6e1aa828","repo":"grafana/k6","slug":"getting-full-page-size-w","errorCode":null,"errorMessage":"getting full page size: %w","messagePattern":"getting full page size: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/screenshotter.go","lineNumber":388,"sourceCode":"\tformat := opts.Format\n\n\t// Infer file format by path\n\tif opts.Path != \"\" && opts.Format != \"png\" && opts.Format != \"jpeg\" {\n\t\tif strings.HasSuffix(opts.Path, \".jpg\") || strings.HasSuffix(opts.Path, \".jpeg\") {\n\t\t\tformat = \"jpeg\"\n\t\t}\n\t}\n\n\tviewportSize, err := s.originalViewportSize(p)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting original viewport size: %w\", err)\n\t}\n\toriginalSize := p.emulatedSize\n\n\tif opts.FullPage { //nolint:nestif\n\t\tfullPageSize, sizeErr := s.fullPageSize(p)\n\t\tif sizeErr != nil {\n\t\t\treturn nil, fmt.Errorf(\"getting full page size: %w\", sizeErr)\n\t\t}\n\t\tdocumentRect := &Rect{\n\t\t\tX:      0,\n\t\t\tY:      0,\n\t\t\tWidth:  fullPageSize.Width,\n\t\t\tHeight: fullPageSize.Height,\n\t\t}\n\t\tfitsViewport := fullPageSize.Width <= viewportSize.Width && fullPageSize.Height <= viewportSize.Height\n\t\tif !fitsViewport {\n\t\t\tdefer func() {\n\t\t\t\tif restoreErr := s.restoreViewport(p, originalSize); restoreErr != nil {\n\t\t\t\t\terr = errors.Join(err, fmt.Errorf(\"restoring viewport to %s: %w\",\n\t\t\t\t\t\tviewportSize, restoreErr))\n\t\t\t\t}\n\t\t\t}()\n\t\t\tif err := p.setViewportSize(s.ctx, fullPageSize); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"setting viewport size to %s: %w\",\n\t\t\t\t\tfullPageSize, err)","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/screenshotter.go#L370-L406","documentation":"Raised in screenshotPage when opts.FullPage is true and fullPageSize (obtained by evaluating page dimensions over CDP) cannot be retrieved. The full page size is required to enlarge the viewport to the whole scrollable document before capturing; the error fires when that underlying evaluation/CDP call fails — typically due to a navigation destroying the execution context, a closing page, or a broken CDP session.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/screenshotter.go:375 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Take the screenshot only after the page has fully loaded (waitForLoadState)","Avoid concurrent navigations while capturing full-page screenshots","Retry the screenshot on a stable page","If the page is extremely large, screenshot specific clips instead of fullPage"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-09-20T22:01:45.163Z","contentChangedAt":"2026-09-20T22:01:45.163Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}