Skip to content

Commit 7c102d4

Browse files
authored
Add nil check to file watcher (#1249)
1 parent 66722ca commit 7c102d4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

internal/watcher/file/file_watcher_service.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,17 @@ func (fws *FileWatcherService) Watch(ctx context.Context, ch chan<- FileUpdateMe
8282
}
8383

8484
return
85-
case event := <-fws.watcher.Events:
86-
fws.handleEvent(ctx, event)
8785
case <-instanceWatcherTicker.C:
8886
fws.checkForUpdates(ctx, ch)
89-
case watcherError := <-fws.watcher.Errors:
90-
slog.ErrorContext(ctx, "Unexpected error in file watcher", "error", watcherError)
87+
}
88+
89+
if fws.watcher != nil {
90+
select {
91+
case event := <-fws.watcher.Events:
92+
fws.handleEvent(ctx, event)
93+
case watcherError := <-fws.watcher.Errors:
94+
slog.ErrorContext(ctx, "Unexpected error in file watcher", "error", watcherError)
95+
}
9196
}
9297
}
9398
}

0 commit comments

Comments
 (0)