-
Notifications
You must be signed in to change notification settings - Fork 4
fix: resolve context leak, unseeded jitter, and broken test utility #14
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
Open
lupppig
wants to merge
7
commits into
logchimp:main
Choose a base branch
from
lupppig:fix/sdk-bugs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ec84e53
fix: resolve context leak, unseeded jitter, and broken test utility
lupppig c1a1ee4
Change remote organization name in CLA workflow
lupppig b237cc7
Update remote organization name in CLA workflow
lupppig 893137d
Update signed commit message in CLA workflow
lupppig eed53de
Modify signed commit message in CLA workflow
lupppig 32c9a4d
fix: resolve context and connection leaks in request handler and test…
lupppig 3597209
fix: resolve context leak and revert workflow changes
lupppig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: logchimp/logchimp-go
Length of output: 773
🏁 Script executed:
Repository: logchimp/logchimp-go
Length of output: 2469
🏁 Script executed:
Repository: logchimp/logchimp-go
Length of output: 1371
🏁 Script executed:
Repository: logchimp/logchimp-go
Length of output: 1931
🌐 Web query:
http.Client.Do returns response with error Go standard library behavior💡 Result:
In Go’s standard library (
net/http),(*http.Client).Do(req)follows this contract:resp != nil, err == niland must read/closeresp.Body. [1]err != nilmeans either:CheckRedirect), orresp != nilanderr != niloccur is whenCheckRedirectfails (including the default redirect policy such as “stopped after too many redirects”). In that case,resp.Bodyis already closed. [1][2]Dois a*url.Error(useful forTimeout()checks, etc.). [1]Practical handling pattern:
Sources: [1]
net/httpdocs forClient.Do(pkg.go.dev) (pkg.go.dev), [2] source-level explanation/examples of the redirect special-case (stackoverflow.com)Citations:
🏁 Script executed:
rg -n "CustomHTTPDoer" internal/requestconfig/requestconfig.goRepository: logchimp/logchimp-go
Length of output: 166
🏁 Script executed:
rg -B 5 -A 5 "interface.*HTTPDoer\|type HTTPDoer" internal/Repository: logchimp/logchimp-go
Length of output: 46
🏁 Script executed:
rg -n "HTTPDoer" --type goRepository: logchimp/logchimp-go
Length of output: 465
🏁 Script executed:
Repository: logchimp/logchimp-go
Length of output: 561
🏁 Script executed:
Repository: logchimp/logchimp-go
Length of output: 889
Close response bodies in all error paths to avoid connection leaks with custom HTTPDoer implementations.
While
http.Client.Dotypically doesn't return non-nil response with context errors, this code supports customHTTPDoerimplementations that may violate this contract. Additionally, the code inconsistently closes response bodies: it properly closes in the retry loop (line 506-508) but not in error paths.Two locations need fixing:
ctx.Err()return pathhandlererror return path🐛 Suggested fix
if ctx != nil && ctx.Err() != nil { + if res != nil && res.Body != nil { + res.Body.Close() + } if cancel != nil { cancel() cancel = nil } return ctx.Err() } ... if err != nil { + if res != nil && res.Body != nil { + res.Body.Close() + } if cancel != nil { cancel() cancel = nil } return err }📝 Committable suggestion
🤖 Prompt for AI Agents