grafana/k6 · error

fetching response body

Error message

fetching response body: %w

What it means

Wrap of the CDP Network.getResponseBody command in Response.fetchBody: the browser's response cache is queried for the request's body, retrying up to 5 times with 100ms delays only for the transient "No data found for resource with given identifier" error. This wrap means the final attempt still failed — the target/session closed, the response was evicted from the browser cache, or the resource genuinely has no body.

Solutions

  1. Call response.body()/text()/json() promptly after receiving the response, before the browser evicts cached bodies
  2. Avoid forcing strict resource-type filters that prevent bodies from being cached
  3. Retry the request if the body fetch failed due to a navigation racing the read
  4. Check for a crashed or closed browser session if all body fetches fail
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/http.go:610 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18). Data as JSON: /api/errors/87cfeea60d66bc41. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/http.go:609

	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 8d06114777)