fix: use new http transport for webhook handler #19462
Merged
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.Transport
maintains a connection pool.Now we'll be cloning
http.DefaultTransport
whenever 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.