Skip to content

Commit

Permalink
fix: Leaking yamux session after HTTP handler is closed
Browse files Browse the repository at this point in the history
Closes #317. We depended on the context canceling the yamux connection,
but this isn't a sync operation. Explicitly calling close ensures the
handler waits for yamux to complete before exit.
  • Loading branch information
kylecarbs committed Feb 18, 2022
1 parent 4c71ff9 commit 4932ba7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions coderd/provisionerdaemons.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func (api *api) provisionerDaemonsServe(rw http.ResponseWriter, r *http.Request)
_ = conn.Close(websocket.StatusInternalError, fmt.Sprintf("multiplex server: %s", err))
return
}
defer func() {
_ = session.Close()
}()
mux := drpcmux.New()
err = proto.DRPCRegisterProvisionerDaemon(mux, &provisionerdServer{
ID: daemon.ID,
Expand Down

0 comments on commit 4932ba7

Please sign in to comment.