{"record":{"id":"87cfeea60d66bc41","repo":"grafana/k6","slug":"fetching-response-body-w","errorCode":null,"errorMessage":"fetching response body: %w","messagePattern":"fetching response body: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/http.go","lineNumber":609,"sourceCode":"\tvar body []byte\n\tvar err error\n\tmaxRetries := 5\n\tfor i := 0; i <= maxRetries; i++ {\n\t\tbody, err = action.Do(cdp.WithExecutor(r.ctx, r.request.frame.manager.session))\n\t\tif err == nil {\n\t\t\tbreak\n\t\t}\n\t\tif strings.Contains(err.Error(), \"No data found for resource with given identifier\") {\n\t\t\tif i == maxRetries {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\ttime.Sleep(100 * time.Millisecond)\n\t\t\tcontinue\n\t\t}\n\t\tbreak\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"fetching response body: %w\", err)\n\t}\n\tr.bodyMu.Lock()\n\tr.body = body\n\tr.bodyMu.Unlock()\n\n\treturn nil\n}\n\nfunc (r *Response) headersSize() int64 {\n\tsize := 4 // 4 = 2 spaces + 2 line breaks (HTTP/1.1 200 OK\\r\\n)\n\tsize += 8 // httpVersion\n\tsize += 3 // statusCode\n\tsize += len(r.statusText)\n\tr.extraHeadersMu.RLock()\n\tif len(r.extraHeaders) != 0 {\n\t\tfor name, values := range r.extraHeaders {\n\t\t\tfor _, value := range values {\n\t\t\t\tsize += len(name) + len(value) + 4 // 4 = ': ' + '\\r\\n'","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/common/http.go#L591-L627","documentation":"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.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/http.go:610 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call response.body()/text()/json() promptly after receiving the response, before the browser evicts cached bodies","Avoid forcing strict resource-type filters that prevent bodies from being cached","Retry the request if the body fetch failed due to a navigation racing the read","Check for a crashed or closed browser session if all body fetches fail"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}