grafana/k6 · error
updating page frame sessions to offline: %w
Error message
updating page frame sessions to offline: %w
What it means
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.
Source
Thrown at internal/js/modules/k6/browser/common/page.go:878
"sid:%v tid:%v wid:%v err:%v",
p.sessionID(), fs.targetID, fs.windowID, err)
return err
}
}
return nil
}
func (p *Page) updateOffline() error {
p.logger.Debugf("Page:updateOffline", "sid:%v", p.sessionID())
p.frameSessionsMu.RLock()
defer p.frameSessionsMu.RUnlock()
for _, fs := range p.frameSessions {
if err := fs.updateOffline(false); err != nil {
return fmt.Errorf("updating page frame sessions to offline: %w", err)
}
}
return nil
}
func (p *Page) updateHTTPCredentials() error {
p.logger.Debugf("Page:updateHttpCredentials", "sid:%v", p.sessionID())
p.frameSessionsMu.RLock()
defer p.frameSessionsMu.RUnlock()
for _, fs := range p.frameSessions {
if err := fs.updateHTTPCredentials(false); err != nil {
return err
}
}
View on GitHub (pinned to 93accf6570)
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
Example fix
// before
await page.goto('https://example.com/');
await page.setOffline(true); // iframe sessions may be in flux
// after
const context = browser.newContext({ offline: true });
const page = context.newPage();
await page.goto('https://example.com/'); Defensive patterns
Strategy: try-catch
Validate before calling
if (page.isClosed()) throw new Error('cannot toggle offline on closed page'); Try / catch
try {
await page.setOffline(true);
} catch (e) {
if (/updating page frame sessions to offline/.test(e.message)) { /* settle and retry once */ }
else throw e;
} Prevention
- Prefer context-level offline emulation (newContext({offline:true})) over mid-test toggling
- Do not toggle offline during navigation
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- errorText
- getting iframe frame: %w
- getting remote node %q: %w
- updating extra HTTP headers: %w
- updating offline mode for frame %v: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/821753f6e1cba213.
Report an issue: GitHub.