diff --git a/api/watcher/watcher.go b/api/watcher/watcher.go
index 9cea159..33b9a9f 100644
--- a/api/watcher/watcher.go
+++ b/api/watcher/watcher.go
@@ -72,6 +72,7 @@ func (w *commonWatcher) commonLoop() {
defer close(w.in)
var wg sync.WaitGroup
wg.Add(1)
+ defer wg.Wait()
go func() {
// When the watcher has been stopped, we send a Stop request
// to the server, which will remove the watcher and return a
@@ -118,7 +119,6 @@ func (w *commonWatcher) commonLoop() {
}
}
}()
- wg.Wait()
}
// Kill is part of the worker.Worker interface.