diff --git a/internal/modulecontext/module_context.go b/internal/modulecontext/module_context.go index f870de1a0b..e3a473308d 100644 --- a/internal/modulecontext/module_context.go +++ b/internal/modulecontext/module_context.go @@ -1,7 +1,6 @@ package modulecontext import ( - "connectrpc.com/connect" "context" "database/sql" "encoding/json" @@ -11,6 +10,8 @@ import ( "sync" "time" + "connectrpc.com/connect" + "github.com/alecthomas/atomic" "github.com/jpillora/backoff" "golang.org/x/sync/errgroup" @@ -239,7 +240,9 @@ func NewDynamicContext(ctx context.Context, supplier ModuleContextSupplier, modu if errors.As(err, &connectErr) && connectErr.Code() == connect.CodeInternal { cancel(err) - await.Done() + releaseOnce.Do(func() { + await.Done() + }) return false }