grafana/k6 · error
fetching response body: %w
Error message
fetching response body: %w
What it means
Response bodies are fetched lazily over CDP with Network.getResponseBody on the frame manager's session. fetchBody first returns any cached body, then retries up to 5 times with 100ms sleeps specifically for 'No data found for resource with given identifier' (body not yet flushed). This error means the final attempt still failed: the body is genuinely unavailable or the session is gone.
Source
Thrown at internal/js/modules/k6/browser/common/http.go:610
var body []byte
var err error
maxRetries := 5
for i := 0; i <= maxRetries; i++ {
body, err = action.Do(cdp.WithExecutor(r.ctx, r.request.frame.manager.session))
if err == nil {
break
}
if strings.Contains(err.Error(), "No data found for resource with given identifier") {
if i == maxRetries {
break
}
time.Sleep(100 * time.Millisecond)
continue
}
break
}
if err != nil {
return fmt.Errorf("fetching response body: %w", err)
}
r.bodyMu.Lock()
r.body = body
r.bodyMu.Unlock()
return nil
}
func (r *Response) headersSize() int64 {
size := 4 // 4 = 2 spaces + 2 line breaks (HTTP/1.1 200 OK\r\n)
size += 8 // httpVersion
size += 3 // statusCode
size += len(r.statusText)
r.extraHeadersMu.RLock()
if len(r.extraHeaders) != 0 {
for name, values := range r.extraHeaders {
for _, value := range values {
size += len(name) + len(value) + 4 // 4 = ': ' + '\r\n'View on GitHub (pinned to 93accf6570)
Solutions
- Read the response body immediately after obtaining the Response, before further navigation or closing the page
- For intercepted/fulfilled requests, use the content you supplied to fulfill() instead of reading it back through the browser API
- Check the response status and whether the request was cached before attempting a body read
- Keep the browser/context alive until all assertions on bodies complete
Example fix
// before
const res = await page.goto('https://app.example.com');
await page.goto('https://app.example.com/next');
const body = await res.body(); // frame may be gone
// after
const res = await page.goto('https://app.example.com');
const body = await res.body(); // read immediately
await page.goto('https://app.example.com/next'); Defensive patterns
Strategy: retry
Validate before calling
// read bodies before navigating further const res = await page.goto(url); const body = await res.body(); // immediate read
Try / catch
let body;
for (let i = 0; i < 2; i++) {
try { body = await res.body(); break; }
catch (e) {
if (i === 1 || !/fetching response body/.test(String(e.message))) throw e;
await page.waitForTimeout(200);
}
} Prevention
- Read response bodies immediately after receiving them
- Do not read bodies for route.fulfill()-ed requests
- Keep page and context open until body assertions finish
When it happens
Trigger: The frame's manager session cannot serve GetResponseBody: the page navigated away or closed before the body was read, the request was fulfilled by route.fulfill() so no network data exists, the response came from cache/service worker without retrievable body, or the target/browser died.
Common situations: Reading res.body()/text()/json() late in the iteration after further navigation; intercepted requests handled with page.route; service-worker-backed responses; calling body accessors after context/page teardown; heavy parallelism causing the browser to drop.
Related errors
- getting response body: %w
- getting response body as text: %w
- errorText
- 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/87cfeea60d66bc41.
Report an issue: GitHub.