Skip to content

Fix connection leaks when requests fail - #544

Merged
Mzack9999 merged 2 commits into
projectdiscovery:mainfrom
bensynapse:fix-error-connection-cleanup
Oct 23, 2026
Merged

Mzack9999 merged 2 commits into
projectdiscovery:mainfrom
bensynapse:fix-error-connection-cleanup

Conversation

@bensynapse

@bensynapse bensynapse commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #547

I run Live Tennis API.

Request write errors, response parse errors and invalid gzip responses leave the connection open. The caller receives no response body to close.

Close the connection on each failure and preserve the original error if cleanup also fails. Successful responses keep their connection until Response.Body.Close.

The regressions cover all three error paths with successful and failed cleanup. A separate test checks successful body ownership.

Go 1.24.1 passes go test -modfile="$modfile" -v -race ./..., go vet -modfile="$modfile" ./... and go build -modfile="$modfile" ./....
The CI example returns fifty HTTP 200 responses. golangci-lint run --timeout 5m passes with version 1.64.8.

The temporary module file raises the Go directive to 1.22.0. Untouched upstream also needs this adjustment. Dependency versions and tracked module files are unchanged.

@Mzack9999
Mzack9999 merged commit 9db7174 into projectdiscovery:main Oct 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed raw requests leave the connection open

2 participants