larksuite/cli · warning

poll read error: %w

Error message

poll read error: %w

What it means

Thrown by pollOnce at internal/auth/app_registration.go:203 when io.ReadAll fails reading the poll response body. Like other poll failures, RegisterAppWithDiscovery treats this as transient: it logs a warning, backs off the interval, and keeps polling until the registration deadline.

Source

Thrown at internal/auth/app_registration.go:203

	form.Set("action", "poll")
	form.Set("device_code", deviceCode)

	req, err := http.NewRequestWithContext(ctx, "POST", appRegistrationEndpoint(brand), strings.NewReader(form.Encode()))
	if err != nil {
		return nil, fmt.Errorf("poll request: %w", err)
	}
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

	resp, err := httpClient.Do(req)
	if err != nil {
		return nil, fmt.Errorf("poll network error: %w", err)
	}
	defer resp.Body.Close()
	logHTTPResponse(resp)

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, fmt.Errorf("poll read error: %w", err)
	}
	var data map[string]interface{}
	if err := json.Unmarshal(body, &data); err != nil {
		return nil, fmt.Errorf("poll parse error: %w", err)
	}
	return data, nil
}

// RegisterAppWithDiscovery polls for credentials, mirroring the official SDK
// flow: the first poll and the (at most one) cross-brand switch are immediate,
// non-error responses without complete credentials keep polling, and one
// deadline from the begin expiry bounds all waits and in-flight requests.
// The returned brand is the one the credentials were issued on.
func RegisterAppWithDiscovery(ctx context.Context, httpClient *http.Client, resp *AppRegistrationResponse, errOut io.Writer) (*AppRegistrationResult, core.LarkBrand, error) {
	if errOut == nil {
		errOut = io.Discard
	}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Allow the CLI to continue — it retries polling automatically with backoff.
  2. If registration ultimately times out, restart the flow on a stabler network.
  3. Investigate proxy/LB idle-timeout settings if this recurs every poll cycle.
  4. Disable VPN or switch networks if connectivity is intermittent.
Defensive patterns

Strategy: retry

Try / catch

data, err := pollOnce(ctx, client, brand, deviceCode)
if err != nil {
    if strings.Contains(err.Error(), "poll read error:") {
        // transient: back off and retry the poll
        time.Sleep(interval * time.Second)
        return pollOnce(ctx, client, brand, deviceCode)
    }
    return nil, err
}

Prevention

When it happens

Trigger: The poll response stream breaks mid-read: server/proxy closes the connection early, chunked encoding truncated, or the context deadline cancels the read partway through the body.

Common situations: Unstable networks during long device-flow waits; load balancers with short idle timeouts killing slow poll responses; VPN drops mid-registration.

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/1b5305ed071856db. Report an issue: GitHub.