{"record":{"id":"d164aa219746c29e","repo":"grafana/k6","slug":"launching-browser-w","errorCode":null,"errorMessage":"launching browser: %w","messagePattern":"launching browser: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/chromium/browser_type.go","lineNumber":292,"sourceCode":"\tflags, err := prepareFlags(opts, &b.vu.State().Options)\n\tif err != nil {\n\t\treturn nil, 0, fmt.Errorf(\"%w\", err)\n\t}\n\n\tdataDir := &storage.Dir{}\n\tif err := dataDir.Make(b.tmpdir(), flags[\"user-data-dir\"]); err != nil {\n\t\treturn nil, 0, fmt.Errorf(\"%w\", err)\n\t}\n\tflags[\"user-data-dir\"] = dataDir.Dir\n\n\tpath, err := executablePath(opts.ExecutablePath, b.envLookupper, exec.LookPath)\n\tif err != nil {\n\t\treturn nil, 0, fmt.Errorf(\"finding browser executable: %w\", err)\n\t}\n\n\tbrowserProc, err := b.allocate(ctx, path, flags, dataDir, logger)\n\tif browserProc == nil {\n\t\treturn nil, 0, fmt.Errorf(\"launching browser: %w\", err)\n\t}\n\n\t// If this context is cancelled we'll initiate an extension wide\n\t// cancellation and shutdown.\n\tbrowserCtx, browserCtxCancel := context.WithCancel(vuCtx)\n\tb.Ctx = browserCtx\n\tbrowser, err := common.NewBrowser(ctx, browserCtx, browserCtxCancel,\n\t\tbrowserProc, opts, logger)\n\tif err != nil {\n\t\treturn nil, 0, fmt.Errorf(\"launching browser: %w\", err)\n\t}\n\n\treturn browser, browserProc.Pid(), nil\n}\n\n// tmpdir returns the temporary directory to use for the browser.\n// It returns the value of the TMPDIR environment variable if set,\n// otherwise it returns an empty string.","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/chromium/browser_type.go#L274-L310","documentation":"BrowserType.allocate failed to start the local browser process (it returned nil), wrapping the underlying launch error — commonly the executable exiting immediately, sandbox errors in containers, or missing shared libraries. Raised inside Launch after flags, data dir, and executable were resolved.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/chromium/browser_type.go:292 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add --no-sandbox via K6_BROWSER_ARGS or options.args when running as root in Docker","Check the wrapped error and browser stderr for missing dependencies (install libnss3 etc.)","Verify the browser binary matches the container architecture"],"exampleFix":null,"handlingStrategy":"fallback","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"}