{"record":{"id":"b833d2dbf7a8ee8c","repo":"xpzouying/xiaohongshu-mcp","slug":"v-b833d2","errorCode":null,"errorMessage":"内置浏览器不可用，拒绝启动: %v","messagePattern":"内置浏览器不可用，拒绝启动: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"browser/browser.go","lineNumber":62,"sourceCode":"\t\tcred = \"***:***\"\n\t}\n\t// 直接在原串替换 userinfo，避免 url.String() 把 * 编码成 %2A（日志变乱码）。\n\treturn strings.Replace(proxyURL, u.User.String()+\"@\", cred+\"@\", 1)\n}\n\nfunc NewBrowser(headless bool, options ...Option) *headless_browser.Browser {\n\tcfg := &browserConfig{}\n\tfor _, opt := range options {\n\t\topt(cfg)\n\t}\n\n\t// 只用内置浏览器，没有别的来源。二进制必须显式传给 go-rod，\n\t// 否则 rod 会自行下载一个默认 Chromium：它不是内置浏览器，也不认识下面\n\t// 这些 flag（未知 flag 被静默忽略，日志照样打印 \"fingerprint enabled\"），\n\t// 属于无声降级。宁可不启动，也不启动一个不对的浏览器。\n\tbinPath, err := EnsureBrowser()\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"内置浏览器不可用，拒绝启动: %v\", err))\n\t}\n\n\topts := []headless_browser.Option{\n\t\theadless_browser.WithHeadless(headless),\n\t\t// 用内置浏览器的默认配置，不强制 UA。\n\t\theadless_browser.WithFingerprint(\"\"), // 空 = 按运行 OS 自动：Linux→windows，mac→macos\n\t\theadless_browser.WithStealthJS(false),\n\t\theadless_browser.WithLanguage(\"zh-CN\"), // 面向小红书\n\t\t// 品牌报 Chrome。\n\t\t// 注：hardware-concurrency 不设，交给 seed 派生。\n\t\theadless_browser.WithExtraFlags(map[string]string{\"fingerprint-brand\": \"Chrome\"}),\n\t}\n\topts = append(opts, headless_browser.WithChromeBinPath(binPath))\n\n\t// 代理（由调用方经 Option 传入，env 读取放在入口层）。\n\tif cfg.proxy != \"\" {\n\t\topts = append(opts, headless_browser.WithProxy(cfg.proxy))\n\t\tlogrus.Infof(\"Using proxy: %s\", maskProxyCredentials(cfg.proxy))","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/browser/browser.go#L44-L80","documentation":"NewBrowser deliberately panics with \"内置浏览器不可用，拒绝启动\" when EnsureBrowser cannot produce the bundled Chromium binary path. This is an intentional fail-fast: the code refuses to silently fall back to a rod-downloaded default Chromium that would ignore the fingerprint flags. It is a panic, not a returned error, so it crashes the process at startup.","triggerScenarios":"EnsureBrowser fails: the bundled browser binary is missing from the image/deployment, the download/extract step failed (no network, disk full), the binary exists but is not executable (permissions) or built for the wrong OS/arch.","commonSituations":"Docker image built without the browser assets or on a mismatched architecture (arm64 image expectations vs amd64 binary); read-only filesystem preventing extraction; corporate proxy blocking the browser download; stripped-down distro missing shared libraries for Chromium.","solutions":["Run EnsureBrowser (or the image build step that installs the bundled browser) once with network access so the binary is present","Check the binary path is executable (chmod +x) and matches the running OS/arch","Verify shared-library dependencies for Chromium exist (ldd) in slim images","Since this panics, wrap startup with recover or call EnsureBrowser yourself first and exit with a clear message"],"exampleFix":"// before\nb := browser.NewBrowser(true) // panics if bundle missing\n// after\nif _, err := browser.EnsureBrowser(); err != nil {\n    log.Fatalf(\"browser bundle unavailable: %v\", err)\n}\nb := browser.NewBrowser(true)","handlingStrategy":"validation","validationCode":"binPath, err := browser.EnsureBrowser()\nif err != nil {\n    log.Fatalf(\"bundled browser unavailable: %v\", err) // explicit, before NewBrowser panics\n}","typeGuard":null,"tryCatchPattern":"func safeNewBrowser(headless bool) (b *headless_browser.Browser, err error) {\n    defer func() { if r := recover(); r != nil { err = fmt.Errorf(\"browser init: %v\", r) } }()\n    return browser.NewBrowser(headless), nil\n}","preventionTips":["Call EnsureBrowser during image build/startup and fail early with a clear log","Verify the binary matches the container OS/arch and is executable","Check Chromium shared-library deps in slim images","Ensure network/proxy allows the one-time browser download"],"tags":["panic","startup","browser","deployment"],"backgroundTag":"browser-binary-missing","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}