Skip to content

Commit fd02f73

Browse files
authored
chore: ensure pubsub messages are delivered in order for in-memory variant (#6474)
PostgreSQL provides this guarantee, which led to some flakes in tests. See: https://github.com/coder/coder/actions/runs/4350034299/jobs/7600478096
1 parent 74632e4 commit fd02f73

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

coderd/database/pubsub_memory.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,16 @@ func (m *memoryPubsub) Publish(event string, message []byte) error {
4646
if !ok {
4747
return nil
4848
}
49+
var wg sync.WaitGroup
4950
for _, listener := range listeners {
50-
go listener(context.Background(), message)
51+
wg.Add(1)
52+
listener := listener
53+
go func() {
54+
defer wg.Done()
55+
listener(context.Background(), message)
56+
}()
5157
}
58+
wg.Wait()
5259

5360
return nil
5461
}

0 commit comments

Comments
 (0)