go-kratos/kratos · error

Discovery watch self failed

Error message

Discovery watch self failed

What it means

Error "Discovery watch self failed" thrown in go-kratos/kratos.

Source

Thrown at contrib/registry/discovery/discovery.go:68

	}
	ctx, cancel := context.WithCancel(context.Background())
	d := &Discovery{
		config:     c,
		ctx:        ctx,
		cancelFunc: cancel,
		apps:       map[string]*appInfo{},
		registry:   map[string]struct{}{},
	}

	d.httpClient = resty.New().
		SetTimeout(40 * time.Second)

	// Discovery self found and watch
	r := d.resolveBuild(_discoveryAppID)
	event := r.Watch()
	_, ok := <-event
	if !ok {
		panic("Discovery watch self failed")
	}
	discoveryIns, ok := r.fetch(context.Background())
	if ok {
		d.newSelf(discoveryIns.Instances)
	}
	go d.selfProc(r, event)

	return d
}

// Close stop all running process including Discovery and register
func (d *Discovery) Close() error {
	d.cancelFunc()
	return nil
}

// selfProc start a goroutine to refresh Discovery self registration information.
func (d *Discovery) selfProc(resolver *Resolve, event <-chan struct{}) {

View on GitHub (pinned to 668db92c2c)

When it happens

Trigger: Thrown at contrib/registry/discovery/discovery.go:68 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of go-kratos/kratos@668db92c2c (2026-08-16). Data as JSON: /api/errors/60cd4ce07c6664c7. Report an issue: GitHub.