Skip to content

Commit

Permalink
fix: module context errors should not cause a negative wait group (#1998
Browse files Browse the repository at this point in the history
)

We were catching multiple calls for `wg.Done()` in the success case, but
when an error was hit
  • Loading branch information
matt2e authored Jul 10, 2024
1 parent 84165e7 commit a8bc627
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/modulecontext/module_context.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package modulecontext

import (
"connectrpc.com/connect"
"context"
"database/sql"
"encoding/json"
Expand All @@ -11,6 +10,8 @@ import (
"sync"
"time"

"connectrpc.com/connect"

"github.com/alecthomas/atomic"
"github.com/jpillora/backoff"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit a8bc627

Please sign in to comment.