fix(coderd): avoid deadlock in (*logFollower).follow (#7983)

This commit is contained in:
Mathias Fredriksson
2023-06-12 18:38:46 +00:00
committed by GitHub
parent aa9dbf2eb3
commit 4068f70d2b
+4
View File
@@ -318,6 +318,10 @@ func (f *logFollower) follow() {
return
}
defer subCancel()
// Move cancel up the stack so it happens before unsubscribing,
// otherwise we can end up in a deadlock due to how the
// in-memory pubsub does mutex locking on send/unsubscribe.
defer cancel()
// we were provided `complete` prior to starting this subscription, so
// we also need to check whether the job is now complete, in case the