mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: clean up idle http conns on wsconncache close (#6471)
See https://github.com/coder/coder/actions/runs/4346769070/jobs/7593243836
This commit is contained in:
@@ -121,6 +121,7 @@ func (c *Cache) Acquire(r *http.Request, id uuid.UUID) (*Conn, func(), error) {
|
||||
}
|
||||
c.connMap.Delete(id.String())
|
||||
c.connGroup.Forget(id.String())
|
||||
transport.CloseIdleConnections()
|
||||
_ = conn.Close()
|
||||
}()
|
||||
return conn, nil
|
||||
|
||||
@@ -126,15 +126,15 @@ func TestCache(t *testing.T) {
|
||||
Host: fmt.Sprintf("127.0.0.1:%d", tcpAddr.Port),
|
||||
Path: "/",
|
||||
})
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
|
||||
defer cancel()
|
||||
req := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||
req = req.WithContext(ctx)
|
||||
conn, release, err := cache.Acquire(req, uuid.Nil)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
defer release()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
|
||||
defer cancel()
|
||||
if !conn.AwaitReachable(ctx) {
|
||||
t.Error("agent not reachable")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user