From 26f186db05c124c928ccbd16afe3b44c1ac6b524 Mon Sep 17 00:00:00 2001 From: Casey Waldren Date: Tue, 16 Jul 2024 15:37:40 -0700 Subject: [PATCH] fix: don't panic if envContext is closed twice --- internal/relayenv/env_context_impl.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/relayenv/env_context_impl.go b/internal/relayenv/env_context_impl.go index 301ec5af..8cd8c432 100644 --- a/internal/relayenv/env_context_impl.go +++ b/internal/relayenv/env_context_impl.go @@ -121,6 +121,7 @@ type envContextImpl struct { doneMonitoringCredentials chan struct{} connectionMapper ConnectionMapper offline bool + closed bool } // Implementation of the DataStoreQueries interface that the streams package uses as an abstraction of @@ -701,6 +702,11 @@ func (c *envContextImpl) FlushMetricsEvents() { func (c *envContextImpl) Close() error { c.mu.Lock() + if c.closed { + c.mu.Unlock() + return nil + } + c.closed = true for _, client := range c.clients { _ = client.Close() }