{"record":{"id":"41b168f9891cb368","repo":"grafana/k6","slug":"restoring-viewport-w","errorCode":null,"errorMessage":"restoring viewport: %w","messagePattern":"restoring viewport: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/screenshotter.go","lineNumber":350,"sourceCode":"\tdocumentRect := bbox\n\tdocumentRect.X += returnVal.X\n\tdocumentRect.Y += returnVal.Y\n\n\tbuf, err := s.screenshot(\n\t\th.frame.page.session,\n\t\tdocumentRect.enclosingIntRect(),\n\t\tnil, // viewportRect\n\t\tformat,\n\t\topts.OmitBackground,\n\t\topts.Quality,\n\t\topts.Path,\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif overriddenViewportSize != nil {\n\t\tif err := s.restoreViewport(h.frame.page, originalViewportSize); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"restoring viewport: %w\", err)\n\t\t}\n\t}\n\n\treturn buf, nil\n}\n\nfunc (s *screenshotter) screenshotPage(p *Page, opts *PageScreenshotOptions) ([]byte, error) {\n\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, originalViewportSize, err := s.originalViewportSize(p)\n\tif err != nil {","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/screenshotter.go#L332-L368","documentation":"Error \"restoring viewport: %w\" thrown in grafana/k6.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/screenshotter.go:350 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}