From 9ed536c9900eac6a5e6f33f479a202bc029bd50f Mon Sep 17 00:00:00 2001 From: Nuno Diegues Date: Wed, 13 Jan 2021 13:10:30 +0000 Subject: [PATCH] TUN-3738: Consume UI events even when UI is disabled Not doing so was causing cloudflared to become stuck after some time. This would happen because the Observer pattern was sending events to the UI channel (that has 16 slots) but no one was consuming those when the UI is not enabled (which is the default case). Hence, events (such as connection disconnect / reconnect) would cause that buffer to be full and cause cloudflared to become apparently stuck, in the sense that the connections would not be reconnected. --- cmd/cloudflared/tunnel/cmd.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/cloudflared/tunnel/cmd.go b/cmd/cloudflared/tunnel/cmd.go index d1f71825..01d09a5b 100644 --- a/cmd/cloudflared/tunnel/cmd.go +++ b/cmd/cloudflared/tunnel/cmd.go @@ -377,6 +377,12 @@ func StartServer( tunnelConfig.HAConnections, ) tunnelInfo.LaunchUI(ctx, log, transportLog, uiCh) + } else { + go func() { + for range uiCh { + // Consume UI events into a noop + } + }() } return waitToShutdown(&wg, errC, shutdownC, graceShutdownC, c.Duration("grace-period"), log)