{"record":{"id":"821753f6e1cba213","repo":"grafana/k6","slug":"updating-page-frame-sessions-to-offline-w","errorCode":null,"errorMessage":"updating page frame sessions to offline: %w","messagePattern":"updating page frame sessions to offline: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/page.go","lineNumber":878,"sourceCode":"\t\t\t\t\"sid:%v tid:%v wid:%v err:%v\",\n\t\t\t\tp.sessionID(), fs.targetID, fs.windowID, err)\n\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (p *Page) updateOffline() error {\n\tp.logger.Debugf(\"Page:updateOffline\", \"sid:%v\", p.sessionID())\n\n\tp.frameSessionsMu.RLock()\n\tdefer p.frameSessionsMu.RUnlock()\n\n\tfor _, fs := range p.frameSessions {\n\t\tif err := fs.updateOffline(false); err != nil {\n\t\t\treturn fmt.Errorf(\"updating page frame sessions to offline: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (p *Page) updateHTTPCredentials() error {\n\tp.logger.Debugf(\"Page:updateHttpCredentials\", \"sid:%v\", p.sessionID())\n\n\tp.frameSessionsMu.RLock()\n\tdefer p.frameSessionsMu.RUnlock()\n\n\tfor _, fs := range p.frameSessions {\n\t\tif err := fs.updateHTTPCredentials(false); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n","sourceCodeStart":860,"sourceCodeEnd":896,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/page.go#L860-L896","documentation":"Page.updateOffline applies network offline emulation (Network.emulateNetworkConditions with offline=true) to every frame session, and this error means at least one frame session's CDP call failed. Because it iterates all frame sessions, a single detached iframe session is enough to fail the whole operation.","triggerScenarios":"page.setOffline(true/false) (or constructing a browser context with offline emulation) on a page containing iframes whose sessions are mid-attach or already detached; page closing concurrently.","commonSituations":"Toggling offline to simulate network loss on a page with third-party iframes; combining offline emulation with page.reload() so frames re-attach while the call runs; running against a closing/crashed browser.","solutions":["Apply offline emulation on the browser context at creation (newContext({offline: true})) rather than flipping it mid-navigation","Call page.setOffline only after the page reaches a stable lifecycle state","Ensure the page and its iframes are not navigating or closing when the call is made","Retry once if it raced with frame attachment"],"exampleFix":"// before\nawait page.goto('https://example.com/');\nawait page.setOffline(true); // iframe sessions may be in flux\n\n// after\nconst context = browser.newContext({ offline: true });\nconst page = context.newPage();\nawait page.goto('https://example.com/');","handlingStrategy":"try-catch","validationCode":"if (page.isClosed()) throw new Error('cannot toggle offline on closed page');","typeGuard":null,"tryCatchPattern":"try {\n  await page.setOffline(true);\n} catch (e) {\n  if (/updating page frame sessions to offline/.test(e.message)) { /* settle and retry once */ }\n  else throw e;\n}","preventionTips":["Prefer context-level offline emulation (newContext({offline:true})) over mid-test toggling","Do not toggle offline during navigation"],"tags":["browser","network","offline-emulation","iframe","cdp"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}