fish2018/pansou · error
[quarkres] request failed
Error message
[quarkres] request failed: %w
What it means
doSearch executes the request via client.Do; a transport-level failure is wrapped as "[quarkres] request failed". Note there is no retry here (unlike quark4k), so a single transient network error aborts the search immediately.
Solutions
- Inspect the wrapped %w error to distinguish DNS vs connection vs TLS causes.
- Test reachability of squark.cc.cd manually (curl -v) from the same host.
- Add a small retry loop with backoff around client.Do for transient failures.
- Set an explicit client Timeout and route via a proxy if the domain is blocked on your network.
Example fix
// before
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("[quarkres] request failed: %w", err)
}
// after
var resp *http.Response
for attempt := 0; attempt < 3; attempt++ {
resp, err = client.Do(req)
if err == nil {
break
}
time.Sleep(time.Duration(attempt+1) * 500 * time.Millisecond)
}
if err != nil {
return nil, fmt.Errorf("[quarkres] request failed: %w", err)
} Defensive patterns
Strategy: retry
Validate before calling
if err := net.DialTimeout("tcp", "squark.cc.cd:443", 3*time.Second); err != nil {
return fmt.Errorf("quarkres endpoint unreachable: %w", err)
} Try / catch
results, err := p.doSearch(client, keyword, ext)
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
// retry with backoff or fail gracefully with empty results
}
} Prevention
- Add a retry loop with backoff around client.Do (none exists today)
- Set an explicit http.Client timeout instead of relying on defaults
- Pre-flight the domain's reachability/DNS at plugin startup
- Route through a proxy if the target domain is blocked on your network
When it happens
Trigger: client.Do(req) returns an error — DNS failure, connection refused/reset, TLS handshake failure, or context timeout when contacting squark.cc.cd.
Common situations: The squark.cc.cd domain is down, expired, or blocked from the host's network; DNS misconfiguration; corporate proxy with TLS interception; no retry means a single blip kills the search.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/0c3f481cb4ceda2f.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/quarkres/quarkres.go:95
}
// doSearch 实际的搜索实现
func (p *QuarkResPlugin) doSearch(client *http.Client, keyword string, ext map[string]interface{}) ([]model.SearchResult, error) {
searchURL := apiBase + url.QueryEscape(keyword)
req, err := http.NewRequest("GET", searchURL, nil)
if err != nil {
return nil, fmt.Errorf("[quarkres] create request failed: %w", err)
}
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36")
req.Header.Set("Accept", "application/json, text/plain, */*")
req.Header.Set("Accept-Language", "zh-CN,zh;q=0.9")
req.Header.Set("Connection", "keep-alive")
req.Header.Set("Referer", "https://squark.cc.cd/")
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("[quarkres] request failed: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return nil, fmt.Errorf("[quarkres] HTTP %d", resp.StatusCode)
}
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("[quarkres] read response failed: %w", err)
}
var ar apiResp
if err := json.Unmarshal(bodyBytes, &ar); err != nil {
return nil, fmt.Errorf("[quarkres] decode response failed: %w", err)
}
if ar.Code != 200 {View on GitHub (pinned to beaa561337)