{"record":{"id":"acdae6e8db98edc0","repo":"fish2018/pansou","slug":"request-failed-page-d-type-s-w","errorCode":null,"errorMessage":"request failed (page %d, type %s): %w","messagePattern":"request failed \\(page (.+?), type (.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/sousou/sousou.go","lineNumber":416,"sourceCode":"\t\t\treq, err := http.NewRequestWithContext(ctx, \"GET\", apiURL, nil)\n\t\t\tif err != nil {\n\t\t\t\tdebugLog(\"创建请求失败 (page %d, type %s): %v\", pageNum, diskType, err)\n\t\t\t\terrChan <- fmt.Errorf(\"create request failed (page %d, type %s): %w\", pageNum, diskType, err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// 设置请求头\n\t\t\treq.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\")\n\t\t\treq.Header.Set(\"Accept\", \"application/json, text/plain, */*\")\n\t\t\treq.Header.Set(\"Accept-Language\", \"zh-CN,zh;q=0.9,en;q=0.8\")\n\t\t\treq.Header.Set(\"Connection\", \"keep-alive\")\n\t\t\treq.Header.Set(\"Referer\", \"https://sousou.pro/\")\n\n\t\t\t// 发送请求\n\t\t\tresp, err := client.Do(req)\n\t\t\tif err != nil {\n\t\t\t\tdebugLog(\"请求失败 (page %d, type %s): %v\", pageNum, diskType, err)\n\t\t\t\terrChan <- fmt.Errorf(\"request failed (page %d, type %s): %w\", pageNum, diskType, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefer resp.Body.Close()\n\n\t\t\tdebugLog(\"收到响应 (page %d, type %s), 状态码: %d\", pageNum, diskType, resp.StatusCode)\n\n\t\t\t// 检查状态码\n\t\t\tif resp.StatusCode != 200 {\n\t\t\t\tdebugLog(\"HTTP错误 (page %d, type %s): %d\", pageNum, diskType, resp.StatusCode)\n\t\t\t\terrChan <- fmt.Errorf(\"HTTP error (page %d, type %s): %d\", pageNum, diskType, resp.StatusCode)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// 读取响应体\n\t\t\trespBody, err := io.ReadAll(resp.Body)\n\t\t\tif err != nil {\n\t\t\t\tdebugLog(\"读取响应失败 (page %d, type %s): %v\", pageNum, diskType, err)\n\t\t\t\terrChan <- fmt.Errorf(\"read response body failed (page %d, type %s): %w\", pageNum, diskType, err)","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/sousou/sousou.go#L398-L434","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nresp, err := client.Do(req)\nif err != nil {\n    errChan <- fmt.Errorf(\"request failed (page %d, type %s): %w\", pageNum, diskType, err)\n    return\n}\n// after\nresp, err := client.Do(req)\nif err != nil {\n    if errors.Is(err, context.DeadlineExceeded) {\n        errChan <- fmt.Errorf(\"request timed out (page %d, type %s): %w\", pageNum, diskType, err)\n    } else {\n        errChan <- fmt.Errorf(\"request failed (page %d, type %s): %w\", pageNum, diskType, err)\n    }\n    return\n}","handlingStrategy":"retry","validationCode":"// pre-check reachability before the search fan-out\nif _, err := http.Head(BaseURL); err != nil {\n    return fmt.Errorf(\"sousou unreachable: %w\", err)\n}","typeGuard":"func isTimeoutErr(err error) bool { return errors.Is(err, context.DeadlineExceeded) || os.IsTimeout(err) }","tryCatchPattern":"results, err := searchSousou(...)\nif err != nil {\n    if strings.Contains(err.Error(), \"request failed\") { /* retry with backoff */ }\n    return err\n}","preventionTips":["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"],"tags":["network","http","timeout"],"backgroundTag":"request-timeout","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}