mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: Leaking yamux session after HTTP handler is closed (#329)
* fix: Leaking yamux session after HTTP handler is closed Closes #317. The httptest server cancels the context after the connection is closed, but if a connection takes a long time to close, the request would never end. This applies a context to the entire listener that cancels on test cleanup. After discussion with @bryphe-coder, reducing the parallel limit on Windows is likely to reduce failures as well. * Switch to windows-2022 to improve decompression * Invalidate cache on matrix OS
This commit is contained in:
+9
-6
@@ -183,12 +183,15 @@ func (c *Conn) init() error {
|
||||
}
|
||||
})
|
||||
c.rtc.OnConnectionStateChange(func(peerConnectionState webrtc.PeerConnectionState) {
|
||||
if c.isClosed() {
|
||||
// Make sure we don't log after Close() has been called.
|
||||
return
|
||||
}
|
||||
c.opts.Logger.Debug(context.Background(), "rtc connection updated",
|
||||
slog.F("state", peerConnectionState))
|
||||
go func() {
|
||||
c.closeMutex.Lock()
|
||||
defer c.closeMutex.Unlock()
|
||||
if c.isClosed() {
|
||||
return
|
||||
}
|
||||
c.opts.Logger.Debug(context.Background(), "rtc connection updated",
|
||||
slog.F("state", peerConnectionState))
|
||||
}()
|
||||
|
||||
switch peerConnectionState {
|
||||
case webrtc.PeerConnectionStateDisconnected:
|
||||
|
||||
Reference in New Issue
Block a user