{"record":{"id":"cf4762e3c9c16684","repo":"grafana/k6","slug":"updating-extra-http-headers-w","errorCode":null,"errorMessage":"updating extra HTTP headers: %w","messagePattern":"updating extra HTTP headers: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame_session.go","lineNumber":1210,"sourceCode":"\t\treturn fmt.Errorf(\"internal error while updating emulated media: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc (fs *FrameSession) updateExtraHTTPHeaders(initial bool) error {\n\tfs.logger.Debugf(\"NewFrameSession:updateExtraHTTPHeaders\", \"sid:%v tid:%v\", fs.session.ID(), fs.targetID)\n\n\t// Merge extra headers from browser context and page, where page specific headers ake precedence.\n\tmergedHeaders := make(network.Headers)\n\tfor k, v := range fs.page.browserCtx.opts.ExtraHTTPHeaders {\n\t\tmergedHeaders[k] = v\n\t}\n\tfor k, v := range fs.page.extraHTTPHeaders {\n\t\tmergedHeaders[k] = v\n\t}\n\tif !initial || len(mergedHeaders) > 0 {\n\t\tif err := fs.networkManager.SetExtraHTTPHeaders(mergedHeaders); err != nil {\n\t\t\treturn fmt.Errorf(\"updating extra HTTP headers: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (fs *FrameSession) updateGeolocation(initial bool) error {\n\tfs.logger.Debugf(\"NewFrameSession:updateGeolocation\", \"sid:%v tid:%v\", fs.session.ID(), fs.targetID)\n\n\tgeolocation := fs.page.browserCtx.opts.Geolocation\n\tif !initial || geolocation != nil {\n\t\taction := emulation.SetGeolocationOverride().\n\t\t\tWithLatitude(geolocation.Latitude).\n\t\t\tWithLongitude(geolocation.Longitude).\n\t\t\tWithAccuracy(geolocation.Accuracy)\n\t\tif err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {\n\t\t\treturn fmt.Errorf(\"%w\", err)\n\t\t}","sourceCodeStart":1192,"sourceCodeEnd":1228,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame_session.go#L1192-L1228","documentation":"Raised when the CDP Network.setExtraHTTPHeaders command fails inside updateExtraHTTPHeaders, which merges browser-context-level and page-level extra HTTP headers (page taking precedence) and pushes them to the frame's network domain. The wrapped error almost always originates from a broken CDP session — target closed, navigation destroying the session, or the browser process having died — not from the header values themselves.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame_session.go:1152 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the page/browser context is still open when setting extraHTTPHeaders","Recreate the browser context if the underlying session was closed by navigation or timeout","Check that header names and values are plain strings (non-string values can fail CDP serialization)","Run with a recent Chromium build bundled with k6 to avoid protocol regressions"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}