micro/go-micro · info

noopWatcher stopped

Error message

noopWatcher stopped

What it means

The noop source's watcher is a placeholder that never produces changes; its Next() blocks on an internal exit channel and only ever returns this error — when Stop() closes the channel. It signals that the watcher was stopped while (or before) a caller waited for the next change.

Source

Thrown at config/source/noop.go:14

package source

import (
	"errors"
)

type noopWatcher struct {
	exit chan struct{}
}

func (w *noopWatcher) Next() (*ChangeSet, error) {
	<-w.exit

	return nil, errors.New("noopWatcher stopped")
}

func (w *noopWatcher) Stop() error {
	close(w.exit)
	return nil
}

// NewNoopWatcher returns a watcher that blocks on Next() until Stop() is called.
func NewNoopWatcher() (Watcher, error) {
	return &noopWatcher{exit: make(chan struct{})}, nil
}

View on GitHub (pinned to 24529f1404)

Solutions

  1. Treat this error as a normal shutdown signal in your watch loop — break out of the loop instead of retrying.
  2. If you need real change notifications, use an actual source (file, envvar, etcd) instead of the noop source.
  3. When shutting down, only Stop() the watcher after cancelling its consumer goroutine, or accept and discard this sentinel error.
  4. In tests, assert on errors.Is/Equal against this message to confirm clean shutdown.

Example fix

// before
for {
    cs, err := w.Next()
    if err != nil {
        log.Fatal(err) // wrong: shutdown is expected
    }
}
// after
for {
    cs, err := w.Next()
    if err != nil {
        break // watcher stopped; exit loop cleanly
    }
}
Defensive patterns

Strategy: try-catch

Try / catch

cs, err := w.Next()
if err != nil {
    return // watcher stopped; exit cleanly
}

Prevention

When it happens

Trigger: Calling Stop() on the noopWatcher while another goroutine is blocked in Next(); the surrounding config Watch loop shutting down the watcher, causing the pending Next() to return this error.

Common situations: Graceful shutdown of a config watcher; tests that stop watchers to unblock Next(); mistakenly using the noop source in production and wondering why no updates ever arrive.

Related errors


AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01). Data as JSON: /api/errors/aa6b75cf73a756cf. Report an issue: GitHub.