Repository navigation
fix: use new http transport for webhook handler - #19462
Merged
Merged
Conversation
… pool, avoiding conflicts over shared connections Signed-off-by: Danny Kopping <dannykopping@gmail.com>
johnstcn
approved these changes
Aug 21, 2025
johnstcn
left a comment
Member
There was a problem hiding this comment.
Should we have some kind of internal "helper" library, perhaps something similar to github.com/hashicorp/go-cleanhttp?
Collaborator
Author
|
I like that idea. It'll be quite a sizeable/wide-ranging refactor I'd imagine, and out of scope for this PR, but probably something we should look into in the future. Thanks for the quick review! |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Closes coder/internal#919
I believe that
Error "request failed: Post \"http://127.0.0.1:46685\": net/http: HTTP/1.x transport connection broken: http: CloseIdleConnections called" does not contain "non-2xx response (500)"indicates that the client is closing what it considers to be an idle connection while another goroutine is using it. This is likely caused by another test (running concurrently) shutting down its http server while this test was still running, and both shared a reference to the globalhttp.DefaultTransport.http.Transportmaintains a connection pool.Now we'll be cloning
http.DefaultTransportwhenever a new webhook handler gets created, ensuring that it maintains its own conn pool.I've added some defensiveness for the type inference, but it's highly unlikely that will change; in which case let's just revert to previous behaviour and log. I considered copying the panic pattern from
tailnet.go, but since this webhook feature is optional, I think it's better to choose a slightly racy implementation than crash the server.