-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Don't update httpClient passed to NewClient #3011
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3011 +/- ##
==========================================
- Coverage 97.91% 97.89% -0.03%
==========================================
Files 150 150
Lines 12980 12984 +4
==========================================
+ Hits 12710 12711 +1
- Misses 192 194 +2
- Partials 78 79 +1 ☔ View full report in Codecov by Sentry. |
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.
Thank you, @WillAbides !
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
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.
LGTM!
Thank you, @valbeat ! |
Use a single instance with tweaked defaults across all the invocations. Plus use newer API of `go-github` (including google/go-github#3011 fix). Previously a default client was used which doesn't have nor request timeout nor idle connection timeout. This resulted in poor `p99` performance since sometimes connections were hanging blocking others to access `github.com`.
* Optimize HTTP client used for GitHub Use a single instance with tweaked defaults across all the invocations. Plus use newer API of `go-github` (including google/go-github#3011 fix). Previously a default client was used which doesn't have nor request timeout nor idle connection timeout. This resulted in poor `p99` performance since sometimes connections were hanging blocking others to access `github.com`. * Renamed to `defaultGitHubClient`
Users can accidentally leak credentials by doing something like this:
This PR fixes that by updating
NewClient
to make a copy of httpClient so that when its transport is updated byWithAuthToken
, the original httpClient won't have its transport updated as well.It also updates
TestWithAuthToken
to check for leaks