{"record":{"id":"a50b7828d0b5b347","repo":"larksuite/cli","slug":"poll-network-error-w","errorCode":null,"errorMessage":"poll network error: %w","messagePattern":"poll network error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/auth/app_registration.go","lineNumber":196,"sourceCode":"\t\t\"&ocv=\" + url.QueryEscape(cliVersion) +\n\t\t\"&from=cli\"\n}\n\n// pollOnce performs one ctx-bound poll request and decodes the payload.\nfunc pollOnce(ctx context.Context, httpClient *http.Client, brand core.LarkBrand, deviceCode string) (map[string]interface{}, error) {\n\tform := url.Values{}\n\tform.Set(\"action\", \"poll\")\n\tform.Set(\"device_code\", deviceCode)\n\n\treq, err := http.NewRequestWithContext(ctx, \"POST\", appRegistrationEndpoint(brand), strings.NewReader(form.Encode()))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"poll request: %w\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\n\tresp, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"poll network error: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tlogHTTPResponse(resp)\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"poll read error: %w\", err)\n\t}\n\tvar data map[string]interface{}\n\tif err := json.Unmarshal(body, &data); err != nil {\n\t\treturn nil, fmt.Errorf(\"poll parse error: %w\", err)\n\t}\n\treturn data, nil\n}\n\n// RegisterAppWithDiscovery polls for credentials, mirroring the official SDK\n// flow: the first poll and the (at most one) cross-brand switch are immediate,\n// non-error responses without complete credentials keep polling, and one","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/internal/auth/app_registration.go#L178-L214","documentation":"Thrown by pollOnce at internal/auth/app_registration.go:196 when httpClient.Do fails while executing the poll POST. This wraps the transport-level error (connection refused, DNS failure, timeout, context deadline). In RegisterAppWithDiscovery these errors are non-fatal: they are logged as a warning, the poll interval backs off (up to 60s), and polling continues until the registration deadline.","triggerScenarios":"Network failure during any poll iteration: DNS resolution failure for the accounts host, connection refused/reset, TLS handshake failure, or the registration deadline context expiring while the request is in flight (context deadline exceeded).","commonSituations":"User behind a firewall blocking accounts.feishu.cn; brand switch to a Lark domain that is unreachable from the user's region; laptop sleeping mid-poll; long polling exceeding the expire_in deadline on slow networks.","solutions":["Wait — the CLI logs '[WARN] app-registration: ...' and automatically retries with backoff until the device code expires.","If it ends with ErrRegistrationTimedOut ('app registration timed out'), restart the registration flow.","Check DNS/connectivity to the accounts host being polled (note the domain may switch between feishu.cn and larksuite.com mid-flow).","Unblock the accounts domain in firewalls/proxies; ensure the context deadline is generous enough (it is derived from the server's expire_in)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if err := net.DialTimeout(\"tcp\", accountsHost+\":443\", 5*time.Second); err != nil {\n    return fmt.Errorf(\"accounts host unreachable before polling: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"result, brand, err := RegisterAppWithDiscovery(ctx, client, resp, errOut)\nif err != nil {\n    if errors.Is(err, ErrRegistrationTimedOut) {\n        // all polls failed network-wise; retry whole flow on a stable network\n    }\n    return err\n}","preventionTips":["Ensure firewall/DNS allows the accounts hosts for both feishu.cn and larksuite.com.","Prevent machine sleep during interactive registration.","Complete browser approval promptly so polling finishes before expire_in."],"tags":["network","polling","device-flow","timeout"],"backgroundTag":"poll-network-error","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}