Skip to content

Commit 088b714

Browse files
cstocktonChris Stockton
andauthored
fix: reloader unittest races on writeWg (#2352)
It's possible for `writerWg.Add(1)` to race with the `notifyFn` passed in `eg.Go`'s call to `pr.watch`. Simple fix is incrementing after writeWg is initialized. Co-authored-by: Chris Stockton <chris.stockton@supabase.io>
1 parent 0096575 commit 088b714

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/reloader/poller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ func TestPoller(t *testing.T) {
168168
defer egCancel()
169169

170170
writerWg := new(sync.WaitGroup)
171+
writerWg.Add(1)
171172
writerDoneCh := make(chan struct{})
172173

173174
notifyCalled := false
@@ -190,7 +191,6 @@ func TestPoller(t *testing.T) {
190191
return pr.watch(egCtx, time.Millisecond*100, notifyFn, errFn)
191192
})
192193

193-
writerWg.Add(1)
194194
eg.Go(func() error {
195195
defer writerWg.Done()
196196

0 commit comments

Comments
 (0)