{"record":{"id":"723f7b2cc6bff4ba","repo":"grafana/k6","slug":"getting-browser-version-information-w","errorCode":null,"errorMessage":"getting browser version information: %w","messagePattern":"getting browser version information: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/js/modules/k6/browser/common/browser.go","lineNumber":809,"sourceCode":"\tproduct := b.version.product\n\t_, after, ok := strings.Cut(product, \"/\")\n\tif !ok {\n\t\treturn product\n\t}\n\treturn after\n}\n\n// fetchVersion returns the browser version information.\nfunc (b *Browser) fetchVersion() (browserVersion, error) {\n\tvar (\n\t\tbv  browserVersion\n\t\terr error\n\t)\n\tbv.protocolVersion, bv.product, bv.revision, bv.userAgent, bv.jsVersion, err = cdpbrowser.\n\t\tGetVersion().\n\t\tDo(cdp.WithExecutor(b.vuCtx, b.conn))\n\tif err != nil {\n\t\treturn browserVersion{}, fmt.Errorf(\"getting browser version information: %w\", err)\n\t}\n\n\t// Adjust the user agent to remove the headless part.\n\t//\n\t// Including Headless might cause issues with some websites that treat headless\n\t// browsers differently. Later on, [BrowserContext] will set the user agent to\n\t// this user agent if not set by the user. This will force [FrameSession] to\n\t// set the user agent to the browser's user agent.\n\t//\n\t// Doing this here provides a consistent user agent across all browser contexts.\n\t// Also, it makes it consistent to query the user agent from the browser.\n\tif b.browserOpts.Headless {\n\t\tbv.userAgent = strings.ReplaceAll(bv.userAgent, \"Headless\", \"\")\n\t}\n\n\treturn bv, nil\n}\n","sourceCodeStart":791,"sourceCodeEnd":827,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/browser.go#L791-L827","documentation":"During browser startup, fetchVersion (browser.go:809) issues the CDP Browser.getVersion call to record protocol version, product, revision, user agent and JS engine version. If that first round-trip fails, browser initialization aborts with this wrapped error. The underlying cause is almost always a broken CDP connection or a chromium binary that launched but immediately died or cannot be talked to.","triggerScenarios":"chromium crashing right after launch (missing shared libraries, sandbox refusal when running as root, bad K6_BROWSER_EXECUTABLE_PATH); the DevTools websocket handshake failing; severe protocol/version skew with an incompatible chromium build.","commonSituations":"Running the browser module in a minimal image missing chromium dependencies instead of the grafana/k6 browser image; K6_BROWSER_EXECUTABLE_PATH pointing at a wrong or ancient binary; running as root without --no-sandbox; system Chrome updated ahead of k6's supported range.","solutions":["Verify the binary launches: run \"$K6_BROWSER_EXECUTABLE_PATH\" --headless --dump-dom about:blank manually and fix whatever fails","Use the grafana/k6 browser image (or install chromium deps); if running as root, pass --no-sandbox via browser launch args","Set K6_BROWSER_LOG=debug to capture the wrapped CDP error text and act on it","Match the chromium version to the one bundled/tested for your k6 release"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// preflight before the run: verify chromium launches in your image\n// \"$K6_BROWSER_EXECUTABLE_PATH\" --headless --dump-dom about:blank >/dev/null && echo ok","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the grafana/k6 browser image or install all chromium dependencies","Verify K6_BROWSER_EXECUTABLE_PATH manually before the first run","Running as root requires --no-sandbox launch args"],"tags":["startup","cdp","environment","version","browser-crash"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}