Skip to content

Commit d38fde1

Browse files
blink-so[bot]f0ssel
andcommitted
Add detailed timing logs around HTTP client request
- Add logging immediately before and after client.Do() call - Track request duration to identify where hang occurs - Reduce timeout to 2 seconds to prevent long waits - Should reveal if client.Do() is hanging or completing Co-authored-by: f0ssel <[email protected]>
1 parent 564d3fe commit d38fde1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

proxy/proxy.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ func (p *Server) forwardHTTPRequest(w http.ResponseWriter, r *http.Request) {
195195

196196
p.logger.Debug("Target URL constructed", "target", targetURL.String())
197197

198-
// Create HTTP client with shorter timeout
198+
// Create HTTP client with very short timeout for debugging
199199
client := &http.Client{
200-
Timeout: 5 * time.Second,
200+
Timeout: 2 * time.Second,
201201
CheckRedirect: func(req *http.Request, via []*http.Request) error {
202202
return http.ErrUseLastResponse // Don't follow redirects
203203
},
@@ -225,7 +225,12 @@ func (p *Server) forwardHTTPRequest(w http.ResponseWriter, r *http.Request) {
225225
p.logger.Debug("About to make HTTP request", "target", targetURL.String())
226226

227227
// Make the request synchronously - this is the key fix
228+
p.logger.Debug("Calling client.Do() now...")
229+
start := time.Now()
228230
resp, err := client.Do(req)
231+
duration := time.Since(start)
232+
p.logger.Debug("client.Do() completed", "duration", duration, "error", err)
233+
229234
if err != nil {
230235
p.logger.Error("Failed to make forward request", "error", err, "target", targetURL.String(), "error_type", fmt.Sprintf("%T", err))
231236
http.Error(w, fmt.Sprintf("Failed to make request: %v", err), http.StatusBadGateway)

0 commit comments

Comments
 (0)