{"record":{"id":"424e027a799c8a1d","repo":"chenhg5/cc-connect","slug":"poll-failed-w","errorCode":null,"errorMessage":"poll failed: %w","messagePattern":"poll failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/feishu.go","lineNumber":600,"sourceCode":"\tinterval := beginRes.Interval\n\tif interval <= 0 {\n\t\tinterval = 5\n\t}\n\texpireIn := beginRes.ExpireIn\n\tif expireIn <= 0 {\n\t\texpireIn = opts.TimeoutSeconds\n\t}\n\n\ttimeoutAt := time.Now().Add(time.Duration(expireIn) * time.Second)\n\tif limitByFlag := time.Now().Add(time.Duration(opts.TimeoutSeconds) * time.Second); limitByFlag.Before(timeoutAt) {\n\t\ttimeoutAt = limitByFlag\n\t}\n\n\tplatformType := \"feishu\"\n\tfor time.Now().Before(timeoutAt) {\n\t\tvar pollRes registrationPollResponse\n\t\tif err := client.registrationCall(\"poll\", map[string]string{\"device_code\": beginRes.DeviceCode}, &pollRes); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"poll failed: %w\", err)\n\t\t}\n\n\t\ttenantBrand := strings.ToLower(strings.TrimSpace(pollRes.UserInfo.TenantBrand))\n\t\tif tenantBrand == \"lark\" {\n\t\t\tplatformType = \"lark\"\n\t\t\tif client.baseURL != accountsLarkBaseURL {\n\t\t\t\tclient.baseURL = accountsLarkBaseURL\n\t\t\t\tif opts.Debug {\n\t\t\t\t\tfmt.Fprintln(os.Stderr, \"[debug] tenant brand detected as lark, switched onboarding domain\")\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif pollRes.ClientID != \"\" && pollRes.ClientSecret != \"\" {\n\t\t\treturn &registrationFlowResult{\n\t\t\t\tAppID:       pollRes.ClientID,\n\t\t\t\tAppSecret:   pollRes.ClientSecret,","sourceCodeStart":582,"sourceCodeEnd":618,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/feishu.go#L582-L618","documentation":"This wraps a transport-level failure of the registration 'poll' call, which the flow issues repeatedly to check whether the user completed QR authorization. Any HTTP/network error during polling aborts the onboarding flow with this wrapped cause.","triggerScenarios":"Inside the polling loop, client.registrationCall(\"poll\", {device_code}, &pollRes) returns a non-nil error — connection drop, timeout, DNS failure, or an HTTP status treated as fatal inside registrationCall — while time.Now().Before(timeoutAt) still holds.","commonSituations":"Losing network mid-scan (mobile user switching Wi-Fi/cellular); the long-running poll loop crossing a proxy idle timeout; registration service flakiness during the wait window; laptop sleep/resume breaking the connection.","solutions":["Re-run the setup flow; the device-code session is not resumable after a fatal poll error.","Check network stability and proxy/firewall idle timeouts (long-poll connections may be killed); disable aggressive proxy connection reaping if applicable.","Inspect debug output for the exact HTTP status/error of the failing poll request.","Prevent sleep/network switches during the QR scan window, then retry."],"exampleFix":"// before\n// network drops mid-poll → poll failed: Post ...: connection reset by peer\n// after\n$ cc-connect setup feishu   # retry on stable network","handlingStrategy":"retry","validationCode":"// preflight: ensure endpoint is reachable and stable before the long poll loop\nif _, err := net.LookupTimeout(host); err != nil { return err }","typeGuard":null,"tryCatchPattern":"for attempts := 0; attempts < 3; attempts++ {\n\terr := runRegistrationFlow(...)\n\tif err == nil || !isNetErr(err) { return err }\n\ttime.Sleep(backoff(attempts))\n}","preventionTips":["Avoid network switches, sleep, or flaky Wi-Fi during QR scanning.","Raise proxy idle timeouts to survive the long poll loop.","Retry the whole flow on transient poll errors — device sessions are not resumable."],"tags":["network","feishu","polling","http"],"backgroundTag":"api-request-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}