Skip to content

Commit 4068f70

Browse files
authored
fix(coderd): avoid deadlock in (*logFollower).follow (coder#7983)
1 parent aa9dbf2 commit 4068f70

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

coderd/provisionerjobs.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ func (f *logFollower) follow() {
318318
return
319319
}
320320
defer subCancel()
321+
// Move cancel up the stack so it happens before unsubscribing,
322+
// otherwise we can end up in a deadlock due to how the
323+
// in-memory pubsub does mutex locking on send/unsubscribe.
324+
defer cancel()
321325

322326
// we were provided `complete` prior to starting this subscription, so
323327
// we also need to check whether the job is now complete, in case the

0 commit comments

Comments
 (0)