fish2018/pansou · error
read response body failed
Error message
read response body failed: %w
What it means
After the API responds, doSearch reads the entire response body with io.ReadAll. If the body cannot be read (connection dropped mid-response, read timeout, aborted transfer), the error is wrapped as "read response body failed".
Solutions
- Inspect the wrapped error for "unexpected EOF" vs timeout to pick the fix
- Retry the request on transient read errors
- Check proxy/LB idle timeouts versus response time
- Consider limiting response size with io.LimitReader to fail fast on anomalies
Example fix
// before
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("read response body failed: %w", err)
}
// after
bodyBytes, err := io.ReadAll(io.LimitReader(resp.Body, 10<<20))
if err != nil {
return nil, fmt.Errorf("read response body failed (status %d): %w", resp.StatusCode, err)
} Defensive patterns
Strategy: retry
Try / catch
// Go
results, err := p.doSearch(ctx, keyword, ext)
if err != nil && strings.Contains(err.Error(), "read response body failed") {
// transient read failure: retry once with backoff
} Prevention
- Use io.LimitReader to bound response size
- Ensure client timeouts exceed slow-response times
- Check intermediary proxy idle timeouts
- Prefer HTTP/2 or keep-alive for stable connections
When it happens
Trigger: io.ReadAll(resp.Body) errors while draining the Jikepan API response: server closes connection early, network interruption mid-transfer, or read deadline exceeded.
Common situations: Unstable network/mobile connections; Jikepan server or an intermediary proxy truncating responses; very large responses hitting a client read timeout; TLS termination issues.
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/b7db707ab7088ec5.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/jikepan/jikepan.go:93
return nil, fmt.Errorf("create request failed: %w", err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("referer", "https://jikepan.xyz/")
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
// 发送请求
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("request failed: %w", err)
}
defer resp.Body.Close()
// 解析响应
var apiResp JikepanResponse
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("read response body failed: %w", err)
}
if err := json.Unmarshal(bodyBytes, &apiResp); err != nil {
return nil, fmt.Errorf("decode response failed: %w", err)
}
// 检查响应状态
if apiResp.Msg != "success" {
return nil, fmt.Errorf("API returned error: %s", apiResp.Msg)
}
// 转换结果格式
results := p.convertResults(apiResp.List)
return results, nil
}
// convertResults 将API响应转换为标准SearchResult格式View on GitHub (pinned to beaa561337)