fish2018/pansou · error
request failed (page , type )
Error message
request failed (page %d, type %s): %w
What it means
The worker's client.Do(req) returned a transport-level error (connection failed, timeout, TLS error, DNS failure), so no response was obtained. The error is wrapped with page and disk type context and pushed to errChan.
Solutions
- Retry with exponential backoff for transient network errors (connection reset, temporary DNS failure)
- Check network connectivity and whether sousou.pro resolves from this host (curl the API URL directly)
- Increase the context timeout if large pages or slow networks cause deadline overruns
- Verify proxy environment (HTTPS_PROXY) if the host requires a proxy to reach the site
Example fix
// before
resp, err := client.Do(req)
if err != nil {
errChan <- fmt.Errorf("request failed (page %d, type %s): %w", pageNum, diskType, err)
return
}
// after
resp, err := client.Do(req)
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
errChan <- fmt.Errorf("request timed out (page %d, type %s): %w", pageNum, diskType, err)
} else {
errChan <- fmt.Errorf("request failed (page %d, type %s): %w", pageNum, diskType, err)
}
return
} Defensive patterns
Strategy: retry
Validate before calling
// pre-check reachability before the search fan-out
if _, err := http.Head(BaseURL); err != nil {
return fmt.Errorf("sousou unreachable: %w", err)
} Type guard
func isTimeoutErr(err error) bool { return errors.Is(err, context.DeadlineExceeded) || os.IsTimeout(err) } Try / catch
results, err := searchSousou(...)
if err != nil {
if strings.Contains(err.Error(), "request failed") { /* retry with backoff */ }
return err
} Prevention
- Use retries with exponential backoff and jitter for transient failures
- Set a realistic context timeout (30s may be tight on slow networks)
- Verify DNS/proxy reachability of sousou.pro from the deployment host
- Reuse a shared http.Client with sane transport timeouts
When it happens
Trigger: client.Do fails for the sousou API request: DNS resolution failure, connection refused/reset, TLS handshake error, or the 30s-style context deadline expires mid-request.
Common situations: No internet/VPN or DNS issues; sousou.pro blocked or unreachable from the host; corporate proxy required but not configured; site temporarily down; request exceeds the context timeout.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/acdae6e8db98edc0.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/sousou/sousou.go:416
req, err := http.NewRequestWithContext(ctx, "GET", apiURL, nil)
if err != nil {
debugLog("创建请求失败 (page %d, type %s): %v", pageNum, diskType, err)
errChan <- fmt.Errorf("create request failed (page %d, type %s): %w", pageNum, diskType, err)
return
}
// 设置请求头
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")
req.Header.Set("Accept", "application/json, text/plain, */*")
req.Header.Set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8")
req.Header.Set("Connection", "keep-alive")
req.Header.Set("Referer", "https://sousou.pro/")
// 发送请求
resp, err := client.Do(req)
if err != nil {
debugLog("请求失败 (page %d, type %s): %v", pageNum, diskType, err)
errChan <- fmt.Errorf("request failed (page %d, type %s): %w", pageNum, diskType, err)
return
}
defer resp.Body.Close()
debugLog("收到响应 (page %d, type %s), 状态码: %d", pageNum, diskType, resp.StatusCode)
// 检查状态码
if resp.StatusCode != 200 {
debugLog("HTTP错误 (page %d, type %s): %d", pageNum, diskType, resp.StatusCode)
errChan <- fmt.Errorf("HTTP error (page %d, type %s): %d", pageNum, diskType, resp.StatusCode)
return
}
// 读取响应体
respBody, err := io.ReadAll(resp.Body)
if err != nil {
debugLog("读取响应失败 (page %d, type %s): %v", pageNum, diskType, err)
errChan <- fmt.Errorf("read response body failed (page %d, type %s): %w", pageNum, diskType, err)View on GitHub (pinned to beaa561337)