Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: drain and close API response bodies #322

Merged
merged 1 commit into from
Jan 19, 2021

Conversation

rhcarvalho
Copy link
Contributor

This fixes the two transport implementations to drain (up to a safe limit) and close the response body from API calls, allowing the net/http client to reuse connections.

Fixes #316.
Closes #317 (replaces it).

Thanks @laoleesch.

This fixes the two transport implementations to drain (up to a safe
limit) and close the response body from API calls, allowing the net/http
client to reuse connections.
//
// maxDrainResponseBytes strikes a balance between reading too much data (if the
// server is misbehaving) and reusing TCP connections.
const maxDrainResponseBytes = 16 << 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why 16 << 10 instead of 1024 * 16 or just 16384, but ok :p

transport.go Show resolved Hide resolved
transport_test.go Show resolved Hide resolved
@rhcarvalho rhcarvalho merged commit 35f2080 into getsentry:master Jan 19, 2021
@rhcarvalho rhcarvalho deleted the fix-keepalive branch January 19, 2021 16:02
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.

Resources leak through net/http transport goroutines
2 participants