Skip to content

Commit 4c750e2

Browse files
blink-so[bot]f0ssel
andcommitted
Fix context cancellation race condition in HTTP forwarding
- Use context.Background() instead of request context for outbound requests - Prevents cancellation when HTTP server completes before client request - Resolves 'context canceled' error in HTTP forwarding - Should fix the race condition causing empty replies Co-authored-by: f0ssel <[email protected]>
1 parent 17d3be0 commit 4c750e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

proxy/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ 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 with context
228-
ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)
228+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
229229
defer cancel()
230230
req = req.WithContext(ctx)
231231

0 commit comments

Comments
 (0)