{"record":{"id":"054de6ff20fd6f91","repo":"xpzouying/xiaohongshu-mcp","slug":"error-054de6","errorCode":null,"errorMessage":"导航到发布页面失败","messagePattern":"导航到发布页面失败","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/publish.go","lineNumber":48,"sourceCode":"}\n\ntype PublishAction struct {\n\tpage *rod.Page\n}\n\nconst (\n\turlOfPublic = `https://creator.xiaohongshu.com/publish/publish?source=official`\n\n\t// contentElemTimeout 查找正文输入框的轮询窗口\n\tcontentElemTimeout = 10 * time.Second\n)\n\nfunc NewPublishImageAction(page *rod.Page) (*PublishAction, error) {\n\n\tpp := page.Timeout(300 * time.Second)\n\n\tif err := pp.Navigate(urlOfPublic); err != nil {\n\t\treturn nil, errors.Wrap(err, \"导航到发布页面失败\")\n\t}\n\n\tif err := pp.WaitLoad(); err != nil {\n\t\tlogrus.Warnf(\"等待页面加载出现问题: %v，继续尝试\", err)\n\t}\n\ttime.Sleep(2 * time.Second)\n\n\tif err := pp.WaitDOMStable(time.Second, 0.1); err != nil {\n\t\tlogrus.Warnf(\"等待 DOM 稳定出现问题: %v，继续尝试\", err)\n\t}\n\ttime.Sleep(1 * time.Second)\n\n\tif err := mustClickPublishTab(pp, \"上传图文\"); err != nil {\n\t\tlogrus.Errorf(\"点击上传图文 TAB 失败: %v\", err)\n\t\treturn nil, err\n\t}\n\n\ttime.Sleep(1 * time.Second)","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/publish.go#L30-L66","documentation":"NewPublishImageAction opens the creator publish page (creator.xiaohongshu.com/publish/publish) via rod's Navigate. '导航到发布页面失败' wraps any Navigate error: navigation was blocked, the request timed out (page had a 300s deadline but ctx/deadline may already be exhausted), the connection failed, or the page was already closed. Callers are publishContent and TestPublish.","triggerScenarios":"Network outage or DNS failure reaching creator.xiaohongshu.com; the rod browser/page was closed before this call (each call creates a fresh navigation); a proxy or firewall blocks the creator domain; navigation aborted by a redirect to a login/risk-control page that resets the frame; the parent ctx was already canceled when entering the function.","commonSituations":"Corporate proxy or region blocking creator.xiaohongshu.com; headless server without outbound access; calling Publish twice where the first flow closed the shared page; browser launched without network permissions in CI containers.","solutions":["Check basic connectivity from the host: curl -I https://creator.xiaohongshu.com/publish/publish — if that fails, fix DNS/proxy/firewall first","Set proxy on the rod browser (launcher flags --proxy-server) if the environment requires one","Verify the page/browser is still alive before calling; reuse one long-lived page and guard ctx cancellation","Retry navigation once after a short backoff; transient CDP 'target closed' errors recover on a fresh attempt","If redirected to a login page, ensure the creator account session/cookies are loaded before constructing the action"],"exampleFix":"// before\naction, err := NewPublishImageAction(page) // page already closed by previous publish\n// after\nif page != nil && !page.IsClosed() {\n    action, err := NewPublishImageAction(page)\n} else {\n    page := browser.MustPage(\"about:blank\")\n    action, err := NewPublishImageAction(page)\n}","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", \"creator.xiaohongshu.com:443\", 5*time.Second)\nif err != nil { return fmt.Errorf(\"creator site unreachable: %w\", err) }\nconn.Close()","typeGuard":"func pageUsable(p *rod.Page) bool { return p != nil && !p.IsClosed() }","tryCatchPattern":"var action *xiaohongshu.PublishAction\nvar err error\nfor i := 0; i < 3; i++ {\n    action, err = xiaohongshu.NewPublishImageAction(page)\n    if err == nil { break }\n    time.Sleep(2*time.Second)\n}\nif err != nil { return fmt.Errorf(\"open publish page: %w\", err) }","preventionTips":["Verify outbound access to creator.xiaohongshu.com from the host/CI container","Configure the rod browser proxy flags when operating behind a corporate proxy","Check page.IsClosed() before reuse; don't share one page across concurrent publishes","Ensure the creator-account session/cookies are loaded so the site doesn't redirect mid-navigation"],"tags":["go","rod","navigation","network","browser-automation"],"backgroundTag":"navigation-failed","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}