We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5bfbf9f commit 0db909cCopy full SHA for 0db909c
coderd/database/pubsub/pubsub.go
@@ -239,8 +239,11 @@ func (p *pgPubsub) Publish(event string, message []byte) error {
239
240
// Close closes the pubsub instance.
241
func (p *pgPubsub) Close() error {
242
- p.cancel()
+ // canceling the context also causes the listener to be closed, so directly
243
+ // close it before canceling the context to avoid the race. If we lost the
244
+ // race we'd return an error about the listener already being closed.
245
err := p.pgListener.Close()
246
+ p.cancel()
247
<-p.listenDone
248
return err
249
}
0 commit comments