Skip to content

Commit 730b30e

Browse files
committed
Block on source start on context cancel.
1 parent ea2aa0e commit 730b30e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/internal/controller/controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ func (c *Controller[request]) startEventSourcesLocked(ctx context.Context) error
356356
case err := <-sourceStartErrChan:
357357
return err
358358
case <-sourceStartCtx.Done():
359-
if didStartSyncingSource.Load() { // We are racing with WaitForSync, wait for it to let it tell us what happened
359+
defer func() { <-sourceStartErrChan }() // Ensure that watch.Start has been called to avoid prematurely releasing lock before accessing c.Queue
360+
if didStartSyncingSource.Load() { // We are racing with WaitForSync, wait for it to let it tell us what happened
360361
return <-sourceStartErrChan
361362
}
362363
if ctx.Err() != nil { // Don't return an error if the root context got cancelled

0 commit comments

Comments
 (0)