juicedata/juicefs · error
error GET request: %v
Error message
error GET request: %v
What it means
getRequest issues the request with http.DefaultClient.Do; any transport-level failure — connection refused, DNS failure, timeout (context deadline exceeded), TLS error — is wrapped as 'error GET request: %v'. The request was created successfully but never completed successfully at the network layer.
Source
Thrown at cmd/debug.go:231
}
}
if listenPort == -1 {
return 0, fmt.Errorf("no valid pprof port found")
}
return listenPort, nil
}
func getRequest(url string, timeout time.Duration) ([]byte, error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
return nil, fmt.Errorf("error creating GET request: %v", err)
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, fmt.Errorf("error GET request: %v", err)
}
if resp.StatusCode != 200 {
return nil, fmt.Errorf("error GET request, status code %d", resp.StatusCode)
}
defer func(body io.ReadCloser) {
if err := body.Close(); err != nil {
logger.Errorf("error closing body: %v", err)
}
}(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("error reading response: %v", err)
}
return body, nil
}
View on GitHub (pinned to c9a67b23e8)
Solutions
- Verify the endpoint manually: `curl -m 3 http://localhost:<port>/debug/pprof/cmdline?debug=1` and compare the failure.
- If the error is `context deadline exceeded`, increase the timeout argument passed to getRequest / reqAndSaveMetric.
- If connection refused, confirm the process is still alive and listening on that port (`ss -ltnp | grep <pid>`), then rerun `juicefs debug`.
- Check proxy environment variables (HTTP_PROXY/HTTPS_PROXY) which http.DefaultClient honors and which can break localhost requests.
- Test metric URLs (prometheus/grafana endpoints) reachability and DNS from the same host.
Example fix
// before
resp, err := getRequest("http://localhost:6060/debug/pprof/heap?debug=1", 3*time.Second)
// after
for i := 0; i < 3; i++ {
resp, err = getRequest(url, 3*time.Second)
if err == nil { break }
time.Sleep(500 * time.Millisecond)
} Defensive patterns
Strategy: retry
Validate before calling
conn, err := net.DialTimeout("tcp", fmt.Sprintf("localhost:%d", port), 2*time.Second)
if err != nil {
return fmt.Errorf("pprof port %d not reachable: %v", port, err)
}
conn.Close() Try / catch
var body []byte
var err error
for i := 0; i < 3; i++ {
body, err = getRequest(url, 5*time.Second)
if err == nil { break }
var ne net.Error
if errors.As(err, &ne) && ne.Timeout() {
time.Sleep(time.Second) // retry only transient timeouts
continue
}
break // connection refused etc. — don't retry blindly
} Prevention
- Use a timeout generous enough for loaded clients (default 3s may be too tight).
- Set NO_PROXY for localhost so http.DefaultClient doesn't route loopback through a proxy.
- Confirm the target process is alive and listening before probing (ss/lsof).
- Distinguish timeout (retryable) from connection-refused (fix target) when handling the wrapped error.
When it happens
Trigger: Called from checkPort (probing localhost:<port>/debug/pprof/cmdline with a 3s timeout) and reqAndSaveMetric (metric/profile URLs) when: the pprof listener is not actually up on that port, the connection is refused/times out, or the metric endpoint host is unreachable.
Common situations: A stale lsof-derived port belongs to a socket that just closed; pprof is listening on IPv6 only and localhost resolves oddly; a 3s timeout is too short on a heavily loaded client (context deadline exceeded); remote metric hosts behind firewalls/VPN drops.
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
- error creating GET request: %v
- error GET request, status code %d
- get range [%v-%v): %s
- bad response status %s
- got %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/0664e7e013064b6b.
Report an issue: GitHub.